我有一个与Fragments相关的问题。
我遇到的问题是,我有一个简单的DialogFragment
。
public class Fragment3 extends DialogFragment {
private Fragment activity;
ViewGroup root;
static Fragment3 newInstance() {
Fragment3 f = new Fragment3();
return f;
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
root = (ViewGroup) inflater.inflate(R.layout.fragment3_layout, container, false);
return root;
}
}
我想从另一个Fragment创建此碎片。
public class ListViewImageAdapter extends BaseAdapter {
private Fragment activity;
....
public ListViewImageAdapter(Fragment activity, ArrayList<Object> listImages) {
this.activity = activity;
...}
....
FragmentTransaction ft = activity.getFragmentManager().beginTransaction();
Fragment3 newFragment = Fragment3.newInstance();
newFragment.show( ft, "dialog");
....
但是我收到了一条消息:
The method show(FragmentManager, String) in the type DialogFragment is not applicable for the arguments (FragmentTransaction, String)