单击时,我想显示一个对话框,但出现错误show
。这部分代码在我的MainActivity扩展和Activity中。相反,我要显示的对话框是在另一个Extended的类中创建的DialogFragment
。
Toast.makeText(this, "Error", Toast.LENGTH_SHORT).show();
DialogFragment df=new DialogTrial();
df.show(this.getFragmentManager(), "MyDialog");
错误:
The method show(android.support.v4.app.FragmentManager, java.lang.String) in the type DialogFragment is not applicable for the arguments (android.app.FragmentManager, java.lang.String)
我什么都试过:this.getFragmentManager()
,getActivity()
,context
,this
但总是同样的错误。
您传递了错误的片段管理器。
df.show(this.getFragmentManager(), "MyDialog");
进入
df.show(this.getSupportFragmentManager(), "MyDialog");
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句