I create an AlertDialog
with an AlertDialog.Builder
and set some items with setItems()
. The dialog is shown but I cannot see any of the items. All I see is the message.
final CharSequence[] items = {"Red", "Green", "Blue"};
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(activity);
dialogBuilder.setMessage("Pick a color");
dialogBuilder.setItems(items, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
// Do anything you want here
}
});
dialogBuilder.create().show();
If I set the PositiveButton
, I can see that button just fine. I also tried setting MultiChoiceItems
and SingleChoiceItems
but neither of these work either.
try this
Use Below Code:-
Use
setTitle
instead ofsetMessage
which sets message body and overrides the items list.Try
alertDialogBuilder.setCustomTitle(view)
If you are using a resource string array you must include the resource packaging. context().getResources().getStringArray(R.array.items);
My list was not showing by using the R.array.items until i gave the pointer the context and resource packaging.
Good luck!
Why don't you go for
setTitle
instead of thesetMessage
? Try withsetTitle("Pick a color")
.I hope it will help you.