java - How do I determine what android widget is calling my function? -
i have several seekbar
s in android app practically same thing (set bass, treble, volume). save typing out new local classes onseekbarchangelistener
per seekbar
, tried make single class in onstoptrackingtouch
determine widget calling it, , proper action.
public class myseekbar implements seekbar.onseekbarchangelistener { int progresschanged = 0; public void onprogresschanged(seekbar seekbar, int progress, boolean fromuser){ progresschanged = progress; } public void onstarttrackingtouch(seekbar seekbar) {} public void onstoptrackingtouch(seekbar seekbar) { // want case statement here switched on widget id/name, // can set appropriate string s (bass, treble, volume) string s = "set_treble " + progresschanged; client.sendmessage(s); } }
how figure out widget calling onstoptrackingtouch
? or there cleaner or better way of doing this?
100 % can determine this;
public void onstoptrackingtouch(seekbar seekbar) { // want case statement here switched on widget id/name, // can set appropriate string s (bass, treble, volume) string s = "set_treble " + progresschanged; client.sendmessage(s); switch (seekbar.getid()) { case r.id.seekvolume: break; case r.id.bass: break; case r.id.trouble: break; default: break; } }
Comments
Post a Comment