I am working on an application in which I have a list populated in an AlertDialog. On some event the dialog appears, showing its Title, Message and the Custom listview. Problem is, when I add more than 4 entries in the list, the Dialog’s message that is set gets hidden by the list view. I want to show list view below the message, no matter how long the list is. Can any one help me out????
Implementation is as follows:
AlertDialog.Builder builder = new AlertDialog.Builder(xActivity.this);
builder.setTitle("Title");
builder.setMessage("Following items are in the List");
final ListView modeList = new ListView(xActivity.this);
ArrayAdapter<String> modeAdapter = new ArrayAdapter<String>(xActivity.this, android.R.layout.simple_list_item_1, android.R.id.text1, simpleArray);
modeList.setAdapter(modeAdapter);
modeList.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
builder.setView(modeList);
builder.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface arg0, int arg1) {
// Do Something
}
}});
final Dialog dialog = builder.create();
dialog.show();
Any help is appreciated…. 🙂
I suggest and think there the best way is to create your custom dialog instead of the predefined AlertDialog. Create your own xml.
http://developer.android.com/guide/topics/ui/dialogs.html
Java