eclipse - How to run the example of ViewPager on Android developer site? -


when try run example https://developer.android.com/reference/android/support/v4/view/viewpager.html on eclipse,the emulator display error dialog .
here logcat:
enter image description here

i don't know why can't run.i build project , copy example code in eclipse,i set android api level 11.and seem ok.

when double click last 1 line of logcat:

at com.lanz.xbp2v4.actionbartabspage.oncreate.java:37 

it redirect code included in oncreate method :

bar.setnavigationmode(actionbar.navigation_mode_tabs);   


so think may wrong in part of code,hope can me!xd

the code in oncreate method:

protected void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);          mviewpager = new viewpager(this);         mviewpager.setid(r.id.pager);         requestwindowfeature(window.feature_no_title);         setcontentview(mviewpager);         // full screen         getwindow().setflags(windowmanager.layoutparams.flag_fullscreen,                 windowmanager.layoutparams.flag_fullscreen);          final actionbar bar = getactionbar();                  bar.setnavigationmode(actionbar.navigation_mode_tabs);              bar.setdisplayoptions(0, actionbar.display_show_title);           mtabsadapter = new tabsadapter(this, mviewpager);         mtabsadapter.addtab(bar.newtab().settext("simple").settablistener((tablistener) this),                 indextab.class, null);         mtabsadapter.addtab(bar.newtab().settext("list").settablistener((tablistener) this),                 tab2.class, null);         mtabsadapter.addtab(bar.newtab().settext("cursor").settablistener((tablistener) this),                 tab3.class, null);          if (savedinstancestate != null) {             bar.setselectednavigationitem(savedinstancestate.getint("tab", 0));         }     } 

i has fixed problem above,but still can't work.at time run example app,the logcat show:
enter image description here

it redirect code included in getitem() method :

 @override  public fragment getitem(int position) {             tabinfo info = mtabs.get(position);             fragment fragment=fragment.instantiate(mcontext, info.clss.getname(), info.args);             return fragment;         } 

is can run example code android developer viewpager?

your getactionbar() returning null.

from link, need make window title visible this.


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -

php - Accessing static methods using newly created $obj or using class Name -