私は、チェックされたlistview
という簡単なダイアログを実装しています。これは私がこれまで何をやったかである:ダイアログボックスで配列リストをsetMultiChoiceItemsに渡す
CharSequence[] items = {"Brand A", "Brand B", "Brand C"};
AlertDialog.Builder builder = new AlertDialog.Builder(StrengthOfDemandsView.this);
builder.setTitle("Select Brands");
final ArrayList seletedItems=new ArrayList();
builder.setMultiChoiceItems(items, null,
new DialogInterface.OnMultiChoiceClickListener() {
// indexSelected contains the index of item (of which checkbox checked)
@Override
public void onClick(DialogInterface dialog, int indexSelected,
boolean isChecked) {
if (isChecked) {
seletedItems.add(indexSelected);
} else{
seletedItems.remove(Integer.valueOf(indexSelected));
}
}
})
.setPositiveButton("OK", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int id) {
}
})
.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int id) {
}
});
dialog = builder.create();
dialog.show();
問題:最初
、私はsetMultiChoiceItems
メソッドに配列を渡すことだし、それが正常に動作しますが、配列の代わりにArrayList
を渡す方法?
ArrayList<Products> brandList = new ArrayList<>();
私はそれが私にこのエラーが発生しますArrayList
setMultiChoiceItems
にメソッドを渡すためにしようとしているときはいつでも:
Cannot resolve method 'setMultiChoiceItems(java.util.ArrayList<com.application.marketvisit.dataItem.Products>, null, anonymous android.content.DialogInterface.OnMultiChoiceClickListener)'
新しい配列を文字列で作成してアダプタに追加する –
はい私は今arrayadapterで作業しています。動作する場合はソリューションを投稿します – 3iL