I have multiple seekbar on the same view :
barheures = (SeekBar)findViewById(R.id.barheures); // make seekbar object
barheures.setOnSeekBarChangeListener(this); // set seekbar listener.
// since we are using this class as the listener the class is "this"
barminutes = (SeekBar)findViewById(R.id.barminutes);
barminutes.setOnSeekBarChangeListener(this);
And here is the listener:
@Override
public void onProgressChanged(SeekBar bar, int progress, boolean fromUser) {
// TODO Auto-generated method stub
Log.v("", "" + bar);
textMinutes.setText("" + progress + "Minute(s)" );
textHours.setText("" + progress + "Heure(s)" );
}
I wanna make something different if the first OR the second bar have moved into the same listener (is it the good practice?), but how to?? Here I have the app that don't do what I want
Now then you have 2 seekbars with the following ids:
Now in the onProgressChanged(SeekBar bar, int progress, boolean fromUser) method, Do the following:
@Override
public void onProgressChanged(SeekBar bar, int progress, boolean fromUser) {
// TODO Auto-generated method stub
Log.v("", "" + bar);
switch (bar.getId()) {
case R.id.barheures:
textHours.setText("" + progress + "Heure(s)");
break;
case R.id.barminutes:
textMinutes.setText("" + progress + "Minute(s)");
break;
}
}