您的位置:首页 > 其它

自定义dialog的异常情况处理

2016-08-18 15:02 169 查看
 Q:java.lang.IllegalStateException:Thespecifiedchildalreadyhasaparent.YoumustcallremoveView()onthechild'sparentfirst.

ViewcustomDialog=View.inflate(getActivity(),R.layout.search_custom_dialog,null);

AlertDialog.Builderdialog;
privatevoidshowAlertDialog(){
ViewGroupparent=(ViewGroup)customDialog.getParent();
if(parent!=null){
parent.removeAllViews();
}
if(dialog==null){
dialog=newAlertDialog.Builder(getActivity());
dialog.setView(customDialog);
dialog.setNegativeButton("取消",null);
dialog.show();

}else{
dialog.show();
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  异常 AlertDialog