Sunday, 15 April 2012

java - Radio Group as Circular Page Indicator -



java - Radio Group as Circular Page Indicator -

i trying utilize radiogroup circularpageindicator. problem radiogroup.oncheckedchangelistener. seems phone call self when onpageselected called. want work vice versa i.e. when select radiobutton should alter view based on location of array index beingness provided. seems if oncheckedchange never called when alter check on radio button , oncheckedchange never triggers.

public class mainactivity extends activity implements radiogroup.oncheckedchangelistener, onpagechangelistener { viewpager mimagepager; imagepageradapter mpageradapter; radiogroup mpageindicator; boolean swipechange = false; int[] mradiobuttonids = new int[] { r.id.radio0, r.id.radio1, r.id.radio2, r.id.radio3, r.id.radio4 }; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); initcomponents(); mpageindicator.setoncheckedchangelistener(this); mimagepager.setadapter(mpageradapter); mimagepager.setonpagechangelistener(this); } /** * */ private void initcomponents() { mpageindicator = (radiogroup) findviewbyid(r.id.radiogroup1); mimagepager = (viewpager) findviewbyid(r.id.imgpager); mpageradapter = new imagepageradapter(); } @override public boolean oncreateoptionsmenu(menu menu) { getmenuinflater().inflate(r.menu.activity_main, menu); homecoming true; } @override public void onpagescrollstatechanged(int arg0) { } @override public void onpagescrolled(int arg0, float arg1, int arg2) { } @override public void onpageselected(int pselectedpageposition) { swipechange = true; mpageindicator.check(mradiobuttonids[pselectedpageposition]); } @override public void oncheckedchanged(radiogroup group, int checkedid) { if (!swipechange) { int itemposition = arrays.aslist(mradiobuttonids).indexof(checkedid); mimagepager.setcurrentitem(itemposition, true); swipechange = false; } } }

note : don't want utilize 3rd party code/lib create custom circular page indicator.

can 1 please point error here. there reason radiogroup not work?

i forgot take @ documentation!

http://developer.android.com/guide/topics/ui/controls/radiobutton.html

java android android-viewpager radio-group viewpagerindicator

No comments:

Post a Comment