简体   繁体   中英

android.support.v4.app.Fragment$InstantiationException

In my app,i get this error :

android.support.v4.app.Fragment$InstantiationException: Unable to instantiate fragment kostas.menu.rssreader.BaseActivity$SampleListFragment: make sure class name exists, is public, and has an empty constructor that is public

I have an activity called BaseActivity in order to present a Sliding Menu ( https://github.com/jfeinstein10/SlidingMenu ).

When i get out of my app (From the open sliding menu view),using the menu button, i get this error as i return!

Your fragment is declared as an instance class of your Activity, so the framework can't access it:

 class SampleListFragment extends SherlockListFragment {
   ...
 }

The easiest way to deal with this is to move the fragment to its own file. This actually makes more sense since you probably want the same menu in several activities.

Note that this constructor will never be used. Android never uses any constructor other than the empty constructor for Activities.

 public BaseActivity(int titleRes) {
   mTitleRes = titleRes;
 }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM