tabs - Using SherlockFragmentActivity works in newer android phone but not older model -


so have tested code on newer android , when test on older version , click on button take me page swipeview , tabs, error:

the application has stopped unexpectedly. please try again.

i have set minimumsdk level in android manifest 7. i'm not sure why won't work on older android phone.

here's code swipeview class:

import com.actionbarsherlock.app.sherlockfragmentactivity; import com.actionbarsherlock.view.menuitem;  import android.app.actionbar; import android.content.intent; import android.os.bundle; import android.support.v4.app.fragment; import android.support.v4.app.fragmentactivity; import android.support.v4.app.fragmentmanager; import android.support.v4.app.fragmentpageradapter; import android.support.v4.app.fragmentstatepageradapter; import android.support.v4.app.navutils; import android.support.v4.app.taskstackbuilder; import android.support.v4.view.viewpager; import android.view.layoutinflater; import android.view.view; import android.view.viewgroup; import android.widget.textview;   public class swipemode extends sherlockfragmentactivity{      democollectionpageradapter mdemocollectionpageradapter;     viewpager mviewpager;      public void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);         setcontentview(r.layout.swipemode);          mdemocollectionpageradapter = new democollectionpageradapter(getsupportfragmentmanager());          // set action bar.         final actionbar actionbar = getactionbar();          // specify home button should show "up" caret, indicating touching         // button take user 1 step in application's hierarchy.         actionbar.setdisplayhomeasupenabled(true);       // set viewpager, attaching adapter.         mviewpager = (viewpager) findviewbyid(r.id.pager);         mviewpager.setadapter(mdemocollectionpageradapter);     }      @override     public boolean onoptionsitemselected(menuitem item) {         switch (item.getitemid()) {             case android.r.id.home:                 // called when home (up) button pressed in action bar.                 // create simple intent starts hierarchical parent activity ,                 // use navutils in support package ensure proper handling of up.                 intent upintent = new intent(this, mainactivity.class);                 if (navutils.shoulduprecreatetask(this, upintent)) {                     // activity not part of application's task, create new task                     // synthesized stack.                     taskstackbuilder.from(this)                             // if there ancestor activities, should added here.                             .addnextintent(upintent)                             .startactivities();                     finish();                 } else {                     // activity part of application's task,                     // navigate hierarchical parent activity.                     navutils.navigateupto(this, upintent);                 }                 return true;         }         return super.onoptionsitemselected(item);     }     public static class democollectionpageradapter extends fragmentstatepageradapter {         public democollectionpageradapter(fragmentmanager fm) {             super(fm);         }          //unimplemented methods automatically added         @override         public fragment getitem(int i) {             // todo auto-generated method stub             fragment fragment = new demoobjectfragment();             bundle args = new bundle();             args.putint(demoobjectfragment.arg_object, + 1); // our object integer :-p             fragment.setarguments(args);             return fragment;         }          //number of pages         @override         public int getcount() {             // todo auto-generated method stub             return 5;         }          @override         public charsequence getpagetitle(int position) {             return "object " + (position + 1);         }     }     public static class demoobjectfragment extends fragment {          public static final string arg_object = "object";          @override         public view oncreateview(layoutinflater inflater, viewgroup container,                 bundle savedinstancestate) {             view rootview = inflater.inflate(r.layout.text_object, container, false);             bundle args = getarguments();             //this part sets integer string text on layouts             ((textview) rootview.findviewbyid(android.r.id.text1)).settext(                     integer.tostring(args.getint(arg_object)));             return rootview;         }     }    } 

use getsupportactionbar() instead of getactionbar(). getactionbar() supported api lvl 11+


Comments

Popular posts from this blog

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -

java - JavaFX 2 slider labelFormatter not being used -