java - pager Cannot resolved as a variable -
i'm trying make action bar tabs, got error:"pager cannot resolved variable..." thansk help.
java code;
package olcay.akgn.fibonaccicalculator; import android.support.v7.app.actionbaractivity; import android.support.v7.app.actionbar; import android.support.v4.app.fragment; import android.support.v4.app.fragmentmanager; import android.support.v4.app.fragmentpageradapter; import android.support.v4.view.viewpager; import android.app.actionbar.tab; import android.app.actionbar.tablistener; import android.app.fragmenttransaction; import android.os.bundle; import android.util.log; import android.view.layoutinflater; import android.view.menu; import android.view.menuitem; import android.view.view; import android.view.viewgroup; import android.os.build; public class mainactivity extends actionbaractivity implements tablistener { android.app.actionbar actionbar; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); viewpager viewpager = (viewpager) findviewbyid(r.id.pager); viewpager.setadapter(new myadapter(getsupportfragmentmanager())); actionbar=getactionbar(); actionbar.setnavigationmode(actionbar.navigation_mode_tabs); tab tab1=actionbar.newtab(); tab1.settext("hesaplayıcı"); tab1.settablistener(this); tab tab2=actionbar.newtab(); tab2.settext("bölünme"); tab2.settablistener(this); actionbar.addtab(tab1); actionbar.addtab(tab2); } @override public void ontabselected(tab tab, fragmenttransaction ft) { log.d("akgn","ontabreselected @ "+" position"+tab.getposition()+"name"+tab.gettext()); } @override public void ontabunselected(tab tab, fragmenttransaction ft) { log.d("akgn","ontabreselected @ "+" position"+tab.getposition()+"name"+tab.gettext()); } @override public void ontabreselected(tab tab, fragmenttransaction ft) { log.d("akgn","ontabreselected @ "+" position"+tab.getposition()+"name"+tab.gettext()); } } class myadapter extends fragmentpageradapter { public myadapter(fragmentmanager fm) { super(fm); // todo auto-generated constructor stub } @override public fragment getitem(int arg0) { fragment fragment=null; if(arg0==0){ fragment=new hesapla(); } if(arg0==0){ fragment=new bolunme (); } return null; } @override public int getcount() { // todo auto-generated method stub return 2; } }
note; begin project video tutorial; https://www.youtube.com/watch?v=iel0ylvvzho
i tried "create "pager" in type id " did not solved issue. please me.
you need declare viewpager
widget on activity_main layout.
never edit r class - automatically generated.
Comments
Post a Comment