单击Cancel
按钮的“关闭警报”对话框不起作用。 Dismiss()
对Alert/dialog
不起作用。请建议在Onclick
按钮事件中写什么。
@Override
public void onClick(View v) {
// Toast toast=Toast.makeText(getActivity(), "Enter number of households here", Toast.LENGTH_SHORT);
final ViewGroup subview=(ViewGroup) getLayoutInflater().
inflate(R.layout.edittext_info_dialog,null,false) ;
TextView tv = (TextView) subview.findViewById(R.id.Info_Title);
tv.setText("Enter number of household in village here");
final AlertDialog.Builder builder= new AlertDialog.Builder(getContext());
builder.setView(subview);
builder .show();
Button Cancel=(Button) subview.findViewById(R.id.Cancel_Info);
Cancel.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(getContext(),"Cancel",Toast.LENGTH_LONG).show();
}
});
}
});
答案 0 :(得分:0)
您,不是建设者解雇
首先,更改行代码
final AlertDialog builder= new AlertDialog.Builder(getContext()).create();
您可以dismiss
或cancel
对话框
@Override
public void onClick(View v) {
Toast.makeText(getc.this,"Cancel",Toast.LENGTH_LONG).show();
builder.dismiss();
}