java - Implementing 2 Seekbars - Both Modify The Exact Same Text? -
i'm attempting implement 2nd seekbar odd reason they're both modifying same text when seekbars moved. i've looked source code , down , can't identify issue (i know i'm overlooking simple - can spot it?)
java:
private long rowid; private edittext nameet; private edittext capet; private edittext codeet; private timepicker timeet; private textview ssidtextview; private textview sbtv; private seekbar bar; private seekbar bar2; private seekbar bar; private seekbar bar2; private textview textprogress,textaction; private textview textprogress2,textaction2; public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.add_country); bar = (seekbar)findviewbyid(r.id.seekbar1); bar.setonseekbarchangelistener(this); bar2 = (seekbar)findviewbyid(r.id.seekbar2); bar2.setonseekbarchangelistener(this); textprogress = (textview)findviewbyid(r.id.textviewprogress); textprogress2 = (textview)findviewbyid(r.id.textviewprogress2); textaction = (textview)findviewbyid(r.id.textviewaction); textaction2 = (textview)findviewbyid(r.id.textviewaction2); } @override public void onprogresschanged(seekbar seekbar, int progress, boolean fromuser) { textprogress.settext(progress+"mbps"); } public void onprogresschanged2(seekbar seekbar2, int progress, boolean fromuser) { textprogress2.settext(progress+"mbps");
the function being called here first one:
@override public void onprogresschanged(seekbar seekbar, int progress, boolean fromuser) { textprogress.settext(progress+"mbps"); }
in function, should check seekbar passed , react accordingly:
@override public void onprogresschanged(seekbar seekbar, int progress, boolean fromuser) { if (seekbar.equals(bar)) {//do bar} else if (seekbar.equals(bar2)) {//do bar2} }
if layout defined in xml (which should anyways in simple app this), compare seekbars ids:
@override public void onprogresschanged(seekbar seekbar, int progress, boolean fromuser) { if (seekbar.getid() == r.id.seekbar_1) {//do bar} else if (seekbar.getid() == r.id.seekbar_2) {//do bar2} }
Comments
Post a Comment