where (text2 ) is a string=(a ,b ,c) and int val2=(1 ,2 ,3) if (a)and (b) is checked it return 13 in a textview how i make it get sum and return 4 instead, here is my code ;
AlertDialog.Builder mBuilder = new AlertDialog.Builder(Main3Activity.this);
mBuilder.setTitle(R.string.dialog_title);
mBuilder.setMultiChoiceItems(text2, checkedItems, new DialogInterface.OnMultiChoiceClickListener() {
@Override
public void onClick(DialogInterface dialog, int which, boolean isChecked) {
if (isChecked){
if (! mUserItems.contains(which)){
mUserItems.add(which);
}
}else {
if (mUserItems.contains(which)){
mUserItems.remove(mUserItems.indexOf(which));
}
}
}
});
mBuilder.setCancelable(false);
mBuilder.setPositiveButton(R.string.ok_label, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
String item = "";
for (int i = 0; i< mUserItems.size(); i++){
item = item + val2[mUserItems.get(i)];
if (i != mUserItems.size() -1){
}
}
mItemSelected.setText(item);
}
});
Aucun commentaire:
Enregistrer un commentaire