我知道有一个Robolectric.shadowOf(Fragment)方法和一个ShadowFragment类,认为它们没有在文档中列出,但我不能使它工作.
myFragment = new MyFragment();
myFragment.onCreateView(LayoutInflater.from(activity), (ViewGroup) activity.findViewById(R.id.container), null);
myFragment.onAttach(activity);
myFragment.onActivityCreated(null);
Run Code Online (Sandbox Code Playgroud)
我正在使用API级别13(Honeycomb).
谢谢.