I want to use the xml code android:onClick="OnClickMethod"
.
However, this means that the method will only be called onClick (i.e. in reality the user has to click the editText twice) instead of onTouch.
Is there an equivalent way that I can call the "OnClickMethod
" on a user touch, instead of user click via XML?
try to use onTouchEvent instead of onClick
This is a good site for performing double click.
http://mobile.tutsplus.com/tutorials/android/android-gesture/
[EDIT 1]
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
editText1.setOnTouchListener(listener);
editText2.setOnTouchListener(listener);
}
OnTouchListener listener = new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
switch (v.getId()) {
case R.id.editText1:
break;
case R.id.editText2:
break;
default:
break;
}
return false;
}
};