multiple OnValueChangedListeners
I have got three NumberPickers and I would like to to detect when the
value is changed in all of them. I currently use them for something else
so I know they work. I tried to do it like a onClickListener when you
switch the Id, but id doesn't work here
public class ..... implements OnValueChangeListener {
// Removed
NumberPicker np1;
// Get the id from xml
np1.setOnValueChangedListener(this);
NumberPicker np2;
// Get the id from xml
np1.setOnValueChangedListener(this);
NumberPicker np3;
// Get the id from xml
np1.setOnValueChangedListener(this);
@Override
public void onValueChange(NumberPicker picker, int oldVal, int newVal) {
// TODO Auto-generated method stub
Log.i("value changed", "true"); // This IS shown
switch (getView().getId()) { // I think this is wrong
case R.id.numberPicker1:
Log.i("value 1", "true"); // Not shown
break;
case R.id.numberPicker2s:
Log.i("value 2", "true"); // Not shown
break;
case R.id.numberPicker3:
Log.i("value 3", "true"); // Not shown
break;
}
}
}
No comments:
Post a Comment