I would like to use two ways to change the input of my EditText field. The EditText field will be only allowing number ("12.34" format).
Normal behavior: When the user touches the EditText it should show the keyboard and just behave like a normal EditText field
Move behavior When the user touches and drags up/down I would like the EditText to be incremented/decremented.
I've searched for this type of implementation, because I expect more people have simimular implementeations, but was unable to find it.
Yesterday I tried the following code, but this doesn't work. The keyboard is still showing during draging and using the sleep is also not a very nice implementation.
Hopefully someone here can help me with a better solution.
Thanks in advance!
inputET.setOnTouchListener(otl);
private OnTouchListener otl = new OnTouchListener() {
public boolean onTouch (View v, MotionEvent event) {
if (v == inputET) {
// to distinguish between touch and drag
if (event.getX > 50) { // drag
float oldPos = event.getX;
thread.sleep(10);
inputET.setText(Float.toString(Float.parseFloat(inputET.getText()) - oldPos - event.getX);
return true;
} else { // touch
return false;
}
}
};