问题
hi, I have been working on a dialog box and i need a ListView inside the dialog box. The problem is i cant use "this" "new ArrayAdapter(this"
Can someone help me?
ListView dialog_ListView = (ListView)dialog.findViewById(R.id.list);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1, comment11);
dialog_ListView.setAdapter(adapter);
回答1:
Maybe this workaround helps you:
ListView dialog_ListView = (ListView)dialog.findViewById(R.id.list);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(dialog_ListView.getContext(),android.R.layout.simple_list_item_1, comment11);
dialog_ListView.setAdapter(adapter);
来源:https://stackoverflow.com/questions/12554842/new-arrayadapterstringthis-error-when-used-in-dialog-null-exception