I make a little android app. In it I need an AlertDialog with multichoice. But I need custom buttons(when button is clicked, it hides, and we can see another button at this place). I got it. But when I'm trying to set all multichoice items true by clicking on my custom buttons, I dont know how to do it. Because my custom buttons in their onclicklistener doesn't have
public void onClick(DialogInterface dialog, int index, boolean status)
{
}
And I dont know how to get to dialog items. I hope my question is clear) Add all my code:
protected Dialog onCreateDialog(int id) {
// AlertDialog.Builder
adb = new AlertDialog.Builder(this);
// multichoice from array and array of checked items
adb.setTitle("Категории");
adb.setMultiChoiceItems(category, category_chkd,
new DialogInterface.OnMultiChoiceClickListener() {
public void onClick(DialogInterface dialog, int which,
boolean isChecked) {
}
});
// dialog buttons from category_buttons.xml
cat_view = (RelativeLayout) getLayoutInflater().inflate(
R.layout.category_buttons, null);
adb.setView(cat_view);
cat_fill_btn = (Button) cat_view
.findViewById(R.id.category_fill_button);
cat_clean_btn = (Button) cat_view
.findViewById(R.id.category_clean_button);
cat_ok_btn = (Button) cat_view.findViewById(R.id.category_ok_button);
//AlertDialog
alert = adb.create();
//button Ok
cat_ok_btn.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
alert.cancel();
}
});
// button to clear the list
cat_clean_btn.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
cat_fill_btn.setVisibility(View.VISIBLE);
}
});
// button to fill the list
cat_fill_btn.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
cat_fill_btn.setVisibility(View.INVISIBLE);
}
});
return alert;
}