我做了一个小小的Android应用。在其中,我需要一个带有多选功能的AlertDialog。但是我需要自定义按钮(单击按钮时它会隐藏,我们可以在此位置看到另一个按钮)。我知道了。但是,当我尝试通过单击自定义按钮将所有选择项设置为true时,我不知道该怎么做。因为我的onclicklistener中的自定义按钮没有
public void onClick(DialogInterface dialog, int index, boolean status)
{
}
Run Code Online (Sandbox Code Playgroud)
而且我不知道如何进入对话项目。我希望我的问题很清楚)添加我的所有代码:
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 …
Run Code Online (Sandbox Code Playgroud) android custom-component android-alertdialog onclicklistener