OnTouchListener not working
I have a few buttons in a tab layout for which the OnClickListener works fine. The purpose of these buttons is to 开发者_JS百科start a new activity when clicked upon. I want my code to work for the touch mode of the phone as well. In other words I wanted to know how to implement the OnTouchListener for the code. Currently I have something like
public boolean onTouch(View v, MotionEvent event) {
startActivity(new Intent().setClass(this, OtherActivity.class));
return true;
}
I am just thinking about it the same way as I would think about the onClick() method but apparently I am wrong.
Any help in this matter would be appreciated. Thanks!
Touching a button on the screen should generate click events the same as using a hardware keypad. Try using the Log object and LogCat to see when methods are called.
精彩评论