Reputation: 4113
I want to create a ToDoList
application for android. For Entering ToDoItem i am using alert , This is working properly. But now i want to show a datepicker also in alert. But it is not adding both view
(EditText and DatePicker) in alert. MyCoding is
final AlertDialog.Builder al = new AlertDialog.Builder(obj);
al.setMessage("ToDo Item");
// Set an EditText view to get user input
final EditText input = new EditText(obj);
final DatePicker dat= new DatePicker(obj);
al.setView(input);
al.setView(dat);
al.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
toDoItems.add(0,input.getText().toString());
aa.notifyDataSetChanged();
}
});
al.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
dialog.dismiss();
}
});
al.show();
Please suggest me what to do ?
Upvotes: 0
Views: 567
Reputation: 4829
AlertDialog displays one, two or three views. But you want to display more than three views, so try using CustomDialog instead.
Upvotes: 1
Reputation: 56925
For that you need to create a custom dialog where you can put any widget in it. Please Look at the following links:
Upvotes: 0