Question

I want to know the process or order of creating the AlertDialog. The order of I asking this question is that I suppose to filter and disable some list item in the AlertDialog. It this must be dynamically. So I chose overwrite the onPrepareDialog(int id, Dialog dialog) method.

First I create a AlertDialog in the onCreateDialog(int id) method

protected Dialog onCreateDialog(int id) {
    --------

    builder.setMultiChoiceItems(itemsId, checkedItems, mListenter);

    ---------
}


protected void onPrepareDialog(int id, Dialog dialog) {
    -----------
    ListView mListView = ((AlertDialog)dialog).getListView();
    mListView.setItemChecked(0, false);
    mListView.invalidateViews();

    View view = mListView.getChildAt(0);
    -----------
}

But these code not work. The first item was still be checked after I check it before. And the ChildView is null when the first time display the dialog, why? How to filer some item in ListView and how to disable but show some of items.

Was it helpful?

Solution

Check and see if my answer over at: How to update array of items in an AlertDialog list built with AlertDialog.builder after creation fits the bill. It works for me, at least.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top