Fragment must be public static class to be properly recreated from instance state
Your top level file is not visible by Android Framework to be managed by the FragmentManager
.
class OverviewFragment extends Fragment
You need to make your class public. Not package default, as you have it right now. Your Fragment should be defined next.
public class OverviewFragment extends Fragment
IllegalStateException: Fragment null must be a public static class to be properly recreated from instance state
get rid of:
@SuppressLint("ValidFragment")
public MapRestaurant(MainActivity fmMain) {
this.fmMain = fmMain;
}
public MainActivity getFmMain() {
return fmMain;
}
public void setFmMain(MainActivity fmMain) {
this.fmMain = fmMain;
}
Android keeps that reference for you. Use getActivity()
to retrieve the hosting Activity
. Same thing applies to contexto = v.getContext();
.
Change
getFmMain().getSupportFragmentManager()
with getFragmentManager()
. If you did import Fragment
s from the support library, in a Fragment
's subclass, getFragmentManager()
, returns the support version of the FragmentManager
. No need of magic
Fragment must be a public static class crash error after upgrade repo v9 in android studio
Is ArrayListFragment in the same java file as the CategoryActivity? If it true, static class means that an instance of ArrayListFragment can be created without creating an instance of CategoryActivity. So each class can have own instance of ArrayListFragment.
Related Topics
How to Implement Zoom Effect for Image View in Android
Retrofit 2 with Only Form-Data
HTML5 <Video> Element on Android Does Not Play
Bypass Android's Hidden API Restrictions
Eclipse Can't Find Android.Support.V4.Widget.Swiperefreshlayout
Extract Notification Text from Parcelable, Contentview or Contentintent
When Does Adt Set Buildconfig.Debug to False
Error: This Android Sdk Requires Android Developer Toolkit Version 22.6.1 or Above
Android Fragment Oncreateview VS. Onactivitycreated
Shaking/Wobble View Animation in Android
How to Make a Listview Transparent in Android
How to Adjust Text Kerning in Android Textview
How to Get Canonical Id from Gcm
How to Access Files Under Assets Folder of Other APK'S
Android Studio Two Flavors with Different Manifest Files