Durga Dutt
Durga Dutt

Reputation: 4113

Android dialog Alert

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

Answers (2)

Balaji.K
Balaji.K

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

Chirag
Chirag

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

Related Questions