I have a fairly simple question.I would like to add a dropdown option or a date chooser dialog to my application.
In the place where Test 2?
is. Is it possible to add a dropdown into the Alert dialog?
It is the first time that I'm programming in Java.
Something like this :
Here is the code:
private void addNew() {
//Invoerveld voor het invoeren van een nieuwe taak.
AlertDialog.Builder alert = new AlertDialog.Builder(this);
alert.setTitle("Nieuwe taak");
alert.setMessage("Which task has to be done?") ;
alert.setMessage("Test2?");
final EditText input = new EditText(this); input.setEnabled(true);
alert.setView(input);
alert.setPositiveButton("Opslaan", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
String description = input.getText().toString();
task_list_adapter.addTask(description);
}
});
alert.setNegativeButton("Annuleer", null);
alert.show();
}
Here my current pop-up window:
I would be amazingly happy If you could help me how to create a dropdown. No functions are necessary. It's just that I need to display the dropdown.
You already are creating a custom view and setting it to your dialog, so I'd say you're halfway through. You just need to use a Spinner , adding the month names you need, or even better using a DatePicker to your layout.
If the sole purpose of your dialog is enabling the user to select a data, I'd suggest going with the available DatePickerDialog . This reference page has a lot of information on how to proceed.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.