My fragment extends BaseFragment which has CMYJsonHttpResponseHandler in it. and if the handler returns error num -622. the basefragment will launch a dialog. and my two fragments in the same Activity. so the dialog will create twice. but i want to crate once in the activity. activity code is like this:
CMYGoodsListFragment commodityFragment = new CMYGoodsListFragment(this);
Bundle commodityBundle = new Bundle();
commodityBundle.putString(KEY_INTENT_ID, "1");
commodityFragment.setArguments(commodityBundle);
fragments.add(commodityFragment);
CMYGoodsListFragment serviceFragment = new CMYGoodsListFragment(this);
Bundle serviceBundle = new Bundle();
serviceBundle.putString(KEY_INTENT_ID, "2");
serviceFragment.setArguments(serviceBundle);
fragments.add(serviceFragment);
使用共享首选项来记住是否显示对话框。
Try with below code.
private Dialog dialog = null;
private void showDialog()
{
if(dialog!=null && dialog.isShowing())
return;
/** Here create dialog */
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.