[英]Show a dialog fragment from another dialog fragment
I have a dialog fragment called DialogFragmentOne inside that i am displaying a recyclerView. 我在其中显示一个名为FragmentFragmentOne的对话框片段,其中显示了一个recyclerView。 On the item click of that recyclerView call an another webservice on post execute of that service i am trying to show another dialogeFragment which also contains recyclerview.
在该recyclerView的项目单击上,在该服务执行后调用另一个Web服务,我试图显示另一个dialogeFragment,其中也包含recyclerview。 but on calling second dialog ishows some error
但是在调用第二个对话框时会出现一些错误
call for second dialogeFragment form service is 调用第二个dialogeFragment表单服务是
protected void onPostExecute(String s) {
super.onPostExecute(s);
if (dialog.isShowing()) {
dialog.dismiss();
}
dialogeInterface.getModifierList(modifierList,hasModifier);
}
and inside FirstDialogeFragment 在FirstDialogeFragment内部
@Override
public void getModifierList(ArrayList<String> modifierList, boolean hasModifier) {
if (hasModifier) {
FragmentManager manager = getFragmentManager();
ModifierListDIalogeFragment dialog = new ModifierListDIalogeFragment();
Bundle bundle = new Bundle();
bundle.putStringArrayList("modifierList", modifierList);
dialog.setArguments(bundle);
dialog.show(manager.beginTransaction(), "dialog");
}
}
and i got an error 我有一个错误
java.lang.NullPointerException: Attempt to invoke virtual method 'android.support.v4.app.FragmentTransaction android.support.v4.app.FragmentManager.beginTransaction()' on a null object reference
at package.xxx.com.pos_system.fragments.ItemListDialogeFragment.getModifierList(ItemListDialogeFragment.java:140)
The reason is context is null .Use Activity context 原因是context为null。Use Activity context
if (hasModifier) {
FragmentManager manager = getActivity().getFragmentManager()
ModifierListDIalogeFragment dialog = new ModifierListDIalogeFragment();
Bundle bundle = new Bundle();
bundle.putStringArrayList("modifierList", modifierList);
dialog.setArguments(bundle);
dialog.show(manager.beginTransaction(), "dialog");
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.