android - get value from SpinnerWheel -
i'm trying value android spinnerwheel. there few post in giving answer , not 1 post shows true information. found 1 link bit descriptive still didn't have result wanted. if can show me how can value , set in textview, great
my code public class mainactivity extends activity { textview textvalue; string value; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); textvalue = (textview)findviewbyid(r.id.textvalue); final abstractwheel mins = (abstractwheel) findviewbyid(r.id.mins); numericwheeladapter minadapter = new numericwheeladapter(this, 0, 59, "%02d"); minadapter.setitemresource(r.layout.wheel_text_centered_dark_back); minadapter.setitemtextresource(r.id.text); mins.setviewadapter(minadapter); //onwheelchangedlistener listener = null; //mins.addchanginglistener(listener); } private onwheelchangedlistener changedlistener = new onwheelchangedlistener() { public void onchanged(abstractwheel wheel, int oldvalue, int newvalue) { string value = string.valueof(newvalue); textvalue.settext(value); } }; }
.
the thing see is, haven´t added listener wheel, because had commented out:
//mins.addchanginglistener(listener);
it must be:
mins.addchanginglistener(changedlistener);
Comments
Post a Comment