I cannot display a list in a dialog with setMultiChoiceItems in Android

I have a method that returns CharSequence [] and is not empty (marked with a log), but does not appear in the dialog box. I need to initialize the boolean [] array; I do not see any error, so maybe I missed something. my code is:

dbManager.open(); final CharSequence[] usrCats = dbManager.getUserCreatedCategories(); dbManager.close(); final boolean[] selections = new boolean[usrCats.length]; alert = b.setTitle(R.string.remove_category) .setMessage(R.string.delete_categories_msg) .setMultiChoiceItems(usrCats, selections, new DialogInterface.OnMultiChoiceClickListener(){ public void onClick(DialogInterface dialog, int which, boolean isChecked){ } }) .setPositiveButton("Create", new DialogInterface.OnClickListener(){ public void onClick(DialogInterface dialog, int which){ } }).create(); } 
+6
source share
2 answers

I don't know why, but setMessage and setMultiChoiceItems cannot work together. When I delete setMessage , the list is displayed just fine.

+8
source
 Dialog _dialog; _dialog = new Dialog(classname.this); _dialog.setTitle("Title"); _dialog.setContentView(R.layout.dialoglist); ListView _output = (ListView) _dialog .findViewById(R.id.dialoglistid); _output.setAdapter(new exmpleadaptor()); // _output.setOnItemClickListener(classname.this); //can use multichoice list option _dialog.show(); } 
0
source

Source: https://habr.com/ru/post/907484/


All Articles