小编Eri*_*ric的帖子

按钮单击时关闭自定义警报对话框

我无法关闭警报对话框.我正在使用布局充气器进行对话,所以我不确定在完成它之后我会怎样关闭它.代码如下:

AlertDialog.Builder dialog = new AlertDialog.Builder(AddData.this);
DialogInterface dia = new DialogInterface();

//Create a custom layout for the dialog box
LayoutInflater inflater = (LayoutInflater)AddData.this.getSystemService(LAYOUT_INFLATER_SERVICE);
View layout = inflater.inflate(R.layout.add_rep_1_set, parent, false);

TextView title = (TextView)layout.findViewById(R.id.rep_1_title);
Button add_item = (Button)layout.findViewById(R.id.add_button);

add_item.setOnClickListener(new OnClickListener()
{
        @Override
        public void onClick(View v)
        {
        //Need this to close the alert dialog box
        }
});

title.setText(workout_items[position]);
dialog.setView(layout);
dialog.show();
Run Code Online (Sandbox Code Playgroud)

我无法调用完成,因为它关闭了启动警报对话框的列表视图,并且对我无法使用dialog.dismiss调用.

您认为我应该怎么做才能解决这个问题?

android android-alertdialog

28
推荐指数
4
解决办法
7万
查看次数

标签 统计

android ×1

android-alertdialog ×1