【发布时间】:2011-08-08 11:18:19
【问题描述】:
我无法关闭警报对话框。我正在使用布局充气机来制作对话框,所以我不确定在完成后我将如何关闭它。代码如下:
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();
我无法调用完成,因为这会关闭启动警报对话框的列表视图,并且我无法使用 dialog.dismiss 调用。
你认为我应该怎么做才能解决这个问题?
【问题讨论】:
标签: android android-alertdialog