When I instantiate this fragment I get a stackoverflow error. I'm trying to have this fragment selected using the navigation drawer defined in my main activity class.
public class MyFragment extends Fragment {
public static MyFragment newInstance() {
return new MyFragment();
}
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
return inflater.inflate(R.layout.page_meet, container, false);
}
public void onViewCreated(View view, Bundle savedInstanceState) {
ViewPager mViewPager = (ViewPager) view.findViewById(R.id.pager);
MyFragmentPagerAdapter mViewPagerAdapter = new MyFragmentPagerAdapter(getChildFragmentManager());
mViewPager.setAdapter(mViewPagerAdapter);
}
public class MyFragmentPagerAdapter extends FragmentPagerAdapter {
public MyFragmentPagerAdapter(FragmentManager fm) {
super(fm);
}
@Override
public Fragment getItem(int position) {
return newInstance();
}
@Override
public int getCount() {
return 2;
}
}
}
Here is the XML file page_meet.xml:
<android.support.v4.view.ViewPager
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:background="#00FF00" >
</LinearLayout>
</android.support.v4.view.ViewPager>
Logcat wasn't very informative:
10-07 03:19:27.910: E/AndroidRuntime(27875): FATAL EXCEPTION: main
10-07 03:19:27.910: E/AndroidRuntime(27875): java.lang.StackOverflowError
10-07 03:19:27.910: E/AndroidRuntime(27875): at android.view.View.canResolveLayoutDirection(View.java:11890)
10-07 03:19:27.910: E/AndroidRuntime(27875): at android.view.View.canResolveLayoutDirection(View.java:11892)
10-07 03:19:27.910: E/AndroidRuntime(27875): at android.view.View.canResolveLayoutDirection(View.java:11892)
10-07 03:19:27.910: E/AndroidRuntime(27875): at android.view.View.canResolveLayoutDirection(View.java:11892)
10-07 03:19:27.910: E/AndroidRuntime(27875): at android.view.View.canResolveLayoutDirection(View.java:11892)
10-07 03:19:27.910: E/AndroidRuntime(27875): at android.view.View.canResolveLayoutDirection(View.java:11892)
10-07 03:19:27.910: E/AndroidRuntime(27875): at android.view.View.canResolveLayoutDirection(View.java:11892)
10-07 03:19:27.910: E/AndroidRuntime(27875): at android.view.View.canResolveLayoutDirection(View.java:11892)
10-07 03:19:27.910: E/AndroidRuntime(27875): at android.view.View.canResolveLayoutDirection(View.java:11892)
10-07 03:19:27.910: E/AndroidRuntime(27875): at android.view.View.canResolveLayoutDirection(View.java:11892)
10-07 03:19:27.910: E/AndroidRuntime(27875): at android.view.View.canResolveLayoutDirection(View.java:11892)
10-07 03:19:27.910: E/AndroidRuntime(27875): at android.view.View.canResolveLayoutDirection(View.java:11892)
10-07 03:19:27.910: E/AndroidRuntime(27875): at android.view.View.canResolveLayoutDirection(View.java:11892)
10-07 03:19:27.910: E/AndroidRuntime(27875): at android.view.View.canResolveLayoutDirection(View.java:11892)
10-07 03:19:27.910: E/AndroidRuntime(27875): at android.view.View.canResolveLayoutDirection(View.java:11892)
10-07 03:19:27.910: E/AndroidRuntime(27875): at android.view.View.canResolveLayoutDirection(View.java:11892)
10-07 03:19:27.910: E/AndroidRuntime(27875): at android.view.View.canResolveLayoutDirection(View.java:11892)
10-07 03:19:27.910: E/AndroidRuntime(27875): at android.view.View.canResolveLayoutDirection(View.java:11892)
10-07 03:19:27.910: E/AndroidRuntime(27875): at android.view.View.canResolveLayoutDirection(View.java:11892)
10-07 03:19:27.910: E/AndroidRuntime(27875): at android.view.View.canResolveLayoutDirection(View.java:11892)
10-07 03:19:27.910: E/AndroidRuntime(27875): at android.view.View.canResolveLayoutDirection(View.java:11892)
10-07 03:19:27.910: E/AndroidRuntime(27875): at android.view.View.canResolveLayoutDirection(View.java:11892)
10-07 03:19:27.910: E/AndroidRuntime(27875): at android.view.View.canResolveLayoutDirection(View.java:11892)
10-07 03:19:27.910: E/AndroidRuntime(27875): at android.view.View.canResolveLayoutDirection(View.java:11892)
10-07 03:19:27.910: E/AndroidRuntime(27875): at android.view.View.canResolveLayoutDirection(View.java:11892)
10-07 03:19:27.910: E/AndroidRuntime(27875): at android.view.View.canResolveLayoutDirection(View.java:11892)
10-07 03:19:27.910: E/AndroidRuntime(27875): at android.view.View.canResolveLayoutDirection(View.java:11892)
10-07 03:19:27.910: E/AndroidRuntime(27875): at android.view.View.canResolveLayoutDirection(View.java:11892)
10-07 03:19:27.910: E/AndroidRuntime(27875): at android.view.View.canResolveLayoutDirection(View.java:11892)
10-07 03:19:27.910: E/AndroidRuntime(27875): at android.view.View.canResolveLayoutDirection(View.java:11892)
10-07 03:19:27.910: E/AndroidRuntime(27875): at android.view.View.canResolveLayoutDirection(View.java:11892)
10-07 03:19:27.910: E/AndroidRuntime(27875): at android.view.View.canResolveLayoutDirection(View.java:11892)
10-07 03:19:27.910: E/AndroidRuntime(27875): at android.view.View.canResolveLayoutDirection(View.java:11892)
10-07 03:19:27.910: E/AndroidRuntime(27875): at android.view.View.canResolveLayoutDirection(View.java:11892)
10-07 03:19:27.910: E/AndroidRuntime(27875): at android.view.View.canResolveLayoutDirection(View.java:11892)
10-07 03:19:27.910: E/AndroidRuntime(27875): at android.view.View.canResolveLayoutDirection(View.java:11892)
10-07 03:19:27.910: E/AndroidRuntime(27875): at android.view.View.canResolveLayoutDirection(View.java:11892)
10-07 03:19:27.910: E/AndroidRuntime(27875): at android.view.View.canResolveLayoutDirection(View.java:11892)
10-07 03:19:27.910: E/AndroidRuntime(27875): at android.view.View.canResolveLayoutDirection(View.java:11892)
10-07 03:19:27.910: E/AndroidRuntime(27875): at android.view.View.canResolveLayoutDirection(View.java:11892)
10-07 03:19:27.910: E/AndroidRuntime(27875): at android.view.View.canResolveLayoutDirection(View.java:11892)
10-07 03:19:27.910: E/AndroidRuntime(27875): at android.view.View.canResolveLayoutDirection(View.java:11892)
10-07 03:19:27.910: E/AndroidRuntime(27875): at android.view.View.canResolveLayoutDirection(View.java:11892)
10-07 03:19:27.910: E/AndroidRuntime(27875): at android.view.View.canResolveLayoutDirection(View.java:11892)
10-07 03:19:27.910: E/AndroidRuntime(27875): at android.view.View.canResolveLayoutDirection(View.java:11892)
10-07 03:19:27.910: E/AndroidRuntime(27875): at android.view.View.canResolveLayoutDirection(View.java:11892)
10-07 03:19:27.910: E/AndroidRuntime(27875): at android.view.View.canResolveLayoutDirection(View.java:11892)
10-07 03:19:27.910: E/AndroidRuntime(27875): at android.view.View.canResolveLayoutDirection(View.java:11892)
10-07 03:19:27.910: E/AndroidRuntime(27875): at android.view.View.canResolveLayoutDirection(View.java:11892)
10-07 03:19:27.910: E/AndroidRuntime(27875): at android.view.View.canResolveLayoutDirection(View.java:11892)
10-07 03:19:27.910: E/AndroidRuntime(27875): at android.view.View.canResolveLayoutDirection(View.java:11892)
10-07 03:19:27.910: E/AndroidRuntime(27875): at android.view.View.canResolveLayoutDirection(View.java:11892)
10-07 03:19:27.910: E/AndroidRuntime(27875): at android.view.View.canResolveLayoutDirection(View.java:11892)
10-07 03:19:27.910: E/AndroidRuntime(27875): at android.view.View.canResolveLayoutDirection(View.java:11892)
10-07 03:19:27.910: E/AndroidRuntime(27875): at android.view.View.canResolveLayoutDirection(View.java:11892)
10-07 03:19:27.910: E/AndroidRuntime(27875): at android.view.View.canResolveLayoutDirection(View.java:11892)
10-07 03:19:27.910: E/AndroidRuntime(27875): at android.view.View.canResolveLayoutDirection(View.java:11892)
10-07 03:19:27.910: E/AndroidRuntime(27875): at android.view.View.canResolveLayoutDirection(View.java:11892)
10-07 03:19:27.910: E/AndroidRuntime(27875): at android.view.View.canResolveLayoutDirection(View.java:11892)
10-07 03:19:27.910: E/AndroidRuntime(27875): at android.view.View.canResolveLayoutDirection(View.java:11892)
10-07 03:19:27.910: E/AndroidRuntime(27875): at android.view.View.canResolveLayoutDirection(View.java:11892)
10-07 03:19:27.910: E/AndroidRuntime(27875): at android.view.View.canResolveLayoutDirec