android - AlertDialog: Why can't I show Message and List together? -
does know why alertdialog
doesn't show list of items when add message .setmessage()
? negative , positive buttons shown, not list. when delete line .setmessage()
works.
this code:
alertdialog.builder myalertdialog = new alertdialog.builder(this.getactivity()); myalertdialog.settitle("options"); myalertdialog.setmessage("choose color."); charsequence[] items = {"red", "blue", "green" }; myalertdialog.setsinglechoiceitems(items, -1, new dialoginterface.onclicklistener() { @override public void onclick(dialoginterface dialog, int which) { // stuff } }); myalertdialog.setnegativebutton("no",new dialoginterface.onclicklistener() { @override public void onclick(dialoginterface dialog, int which) { // stuff } }); myalertdialog.setpositivebutton("yes",new dialoginterface.onclicklistener() { @override public void onclick(dialoginterface dialog, int which) { // stuff } }); myalertdialog.create(); myalertdialog.show();
from docs,
because list appears in dialog's content area, dialog cannot show both message , list , should set title dialog settitle().
the setmessage()
, setsinglechoiceitems()
therefore mutually exclusive.
Comments
Post a Comment