I have an AlertDialog defined this way:
final CharSequence[] items = { "Red", "Green", "Blue", "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten" };
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("Pick a color");
builder.setSingleChoiceItems(items, 0, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int item) {
// Set items uncheckable
Toast.makeText(getApplicationContext(), items[item], Toast.LENGTH_SHORT).show();
}
});
builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
}
});
AlertDialog alert = builder.create();
alert.show();
FIRST QUESTION
Is it possible to mark some of the items as uncheckable?
Although I’m showing various items I what the user understand that the items exist but some of them are uncheckable.
SECOND QUESTION
If there is a way to accomplish my first question, is it possible to put that uncheckable items grayed out?
Thanks,
favolas
Maybe something like:
Here is another way:
See if that works. Also make sure you this after
builder.create();butbefore alert.show()EDIT: For the list items I think you can use getListView() with that you can access the checkable options, and the use
setEnabled(false)