关闭子对象上的alertDialog Android removeView();她先是父母
我想关闭/关闭警报对话框,但当我单击按钮valider时,我出现了以下错误:我不知道哪些视图会出现问题,即使在我的视图“布局”或“v”中没有删除视图的方法 我不太清楚关闭子对象上的alertDialog Android removeView();她先是父母,android,android-alertdialog,Android,Android Alertdialog,我想关闭/关闭警报对话框,但当我单击按钮valider时,我出现了以下错误:我不知道哪些视图会出现问题,即使在我的视图“布局”或“v”中没有删除视图的方法 我不太清楚 v.findViewById(R.id.btn_author).setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View view, MotionEvent motionEvent)
v.findViewById(R.id.btn_author).setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) {
LayoutInflater inflater = (LayoutInflater) LayoutInflater.from(getActivity());
final View layout = inflater.inflate(R.layout.accomplice_layout_solution, null);
layout.setBackgroundColor(colors.getBackMixColor(colors.getForeground_color(), 0.30f));
ListView lv = (ListView) layout.findViewById(R.id.listForm);
adapterAgent = new MyFormAgentAdapter((MainActivity) getActivity(), finalfieldsAgent, realm, colors, R.layout.form_row_item);
lv.setAdapter(adapterAgent);
final AlertDialog.Builder b = new AlertDialog.Builder(getActivity());
b.setView(layout);
b.show();
AllFilds.addAll(finalFields);
layout.findViewById(R.id.btn_valide_form).setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
v.findViewById(R.id.numberPinContainerAuthor).setVisibility(View.VISIBLE);
TextView textView = (TextView) v.findViewById(R.id.numberOfCatsAuthor);
int numbr = 0;
if(AllFilds.size() > 0)
numbr++;
textView.setText(""+numbr);
b.show().dismiss(); // the error is here
}
});
}
return false;
}
});
而不是这个
b.show().dismiss();
试试这个
b.dismiss();
当您两次调用show()方法时,就会出现该错误。请尝试以下代码
Dialog d = b.show(); // here you got the dialog object when u showing you dialog first
if (d!=null &&d.isShowing()){
d.dismiss();
}
改变这个
final AlertDialog.Builder b = new AlertDialog.Builder(getActivity());
b.setView(layout);
b.show();
b.show().dismiss();
到
改变这个
final AlertDialog.Builder b = new AlertDialog.Builder(getActivity());
b.setView(layout);
b.show();
b.show().dismiss();
到
问题是您试图取消尚未显示的对话框。。你为什么要做show().解雇()?这并不意味着老师没有b.disease(),我只得到b.show().disease(),没有b.disease()方法,只有这个b.show().disease();谢谢,因为每个人都遇到了同样的问题,不要忘记像在回答final alertDialog alertDialog=b.show()中那样声明alertDialog final;
if (alertDialog.isShowing())
alertDialog.dismiss();