我給陣列選擇通過警告對話框我想禁用選擇多個選項,如果數組滿禁用複選框項目在alertDialog
我已經能夠停止添加項目陣列到達極限,但不能後禁用複選框
AlertDialog.Builder builder=new AlertDialog.Builder(this);
View view=inflater.inflate(R.layout.dialog_genre,null,false);
builder.setView(view).setTitle("Select Genres");
builder.setMultiChoiceItems(array, checkedGenres, new DialogInterface.OnMultiChoiceClickListener() {
@Override
public void onClick(DialogInterface dialog, int which, boolean isChecked) {
if(isChecked) {
if (!selectedgenre.contains(String.valueOf(which)))
if(selectedgenre.size()<5)
{
selectedgenre.add(String.valueOf(which));
checkedGenres[which]=true;
}
else{
Toast.makeText(getApplicationContext(),"you can't add more genres",Toast.LENGTH_LONG).show();
}
}
else if (selectedgenre.contains(String.valueOf(which)))
{
selectedgenre.remove(String.valueOf(which));
checkedGenres[which]=false;
}
}
}
我要禁用的選擇,即別人的'如果(selectedgenre.size()<5)' – rookieDeveloper
沒有得到你想要做的.. –
如果我的計數達到什麼5我要禁用複選框,用戶應該能夠選擇,你可以看到圖像甚至達到5被允許選擇 – rookieDeveloper