Android: Select items in a multi-select ListView inside AlertDialog
I am new to android development and struggling with how to select certain items in a listview hosted by an alertdialog. In the below code, lv.setItemChecked doesn't work as listview hasn't been generated yet, so I am wondering if there's any ListView or AlertDialog event which confirms that view has been generated. String [] values = {"a","b","c"}; ArrayAdapter<String> adp = new ArrayAdapter<String>(this,android.R.layout.simple_list_item_multiple_choice, values); ListView lv = new ListView(this); lv.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE); lv.setOnItemClickListener(this); lv.setAdapter