java - cannot resolve symbol setOnPageChangeListener -
i couldnot find relevant solution scenario.i working on select respected tab manually on tab swipe..i learning
http://www.androidgreeve.com/2014/01/android-actionbar-navigating-with-swipeable-tabs-and-views.html
in mainactivity ,on adding viewpager.setonpagechangelistener doesnot recognizes ..it thows error ...
cannot resolve symbol setonpagechangelistener
here code
package com.example.administrator.fragmentsexample; import android.support.v7.app.actionbar; import android.support.v4.view.viewpager; import android.os.bundle; import android.support.v7.app.appcompatactivity; import com.example.administrator.adapter.tabspageradapter; public class mainactivity extends appcompatactivity implements actionbar.tablistener { private viewpager viewpager; private tabspageradapter madapter; private actionbar actionbar; // tab titles private string[] tabs = {"social", "organizer", "movies"}; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); // initilization viewpager = (viewpager) findviewbyid(r.id.pager); actionbar = getsupportactionbar(); madapter = new tabspageradapter(getsupportfragmentmanager()); viewpager.setadapter(madapter); actionbar.sethomebuttonenabled(false); actionbar.setnavigationmode(actionbar.navigation_mode_tabs); // adding tabs (string tab_name : tabs) { actionbar.addtab(actionbar.newtab().settext(tab_name) .settablistener(this)); } } @override public void ontabselected(actionbar.tab tab, android.support.v4.app.fragmenttransaction fragmenttransaction) { } @override public void ontabunselected(actionbar.tab tab, android.support.v4.app.fragmenttransaction fragmenttransaction) { } @override public void ontabreselected(actionbar.tab tab, android.support.v4.app.fragmenttransaction fragmenttransaction) { } viewpager.setonpagechangelistener(new viewpager.onpagechangelistener() { @override public void onpageselected(int position) { // on changing page // make respected tab selected actionbar.setselectednavigationitem(position); } @override public void onpagescrolled(int arg0, float arg1, int arg2) { } @override public void onpagescrollstatechanged(int arg0) { } }); }
what missing ?
try move this:
viewpager.setonpagechangelistener(new viewpager.onpagechangelistener() { @override public void onpageselected(int position) { // on changing page // make respected tab selected actionbar.setselectednavigationitem(position); } @override public void onpagescrolled(int arg0, float arg1, int arg2) { } @override public void onpagescrollstatechanged(int arg0) { } });
into oncreate. think current placement of call not make sense. :-)
Comments
Post a Comment