开发者

Android - How to detect a single tap on a LinearLayout?

开发者 https://www.devze.com 2023-04-10 12:08 出处:网络
I have a View and I need to detect a single tap on a LinearLayout. I don\'t care about movements, All I want to dete开发者_JAVA百科ct is a single tap.

I have a View and I need to detect a single tap on a LinearLayout. I don't care about movements, All I want to dete开发者_JAVA百科ct is a single tap. Basically a touch detection just like the touch detection on buttons. How can I achieve this?

myView.setOnTouchListener(new OnTouchListener(){
    @Override
    public boolean onTouch(View v, MotionEvent event) {
        // This gets called so many times on every movement
        return true;
    }
});


I'm pretty sure, this would work aryaxt:

myView.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
       // myView tapped //
    }
});
0

精彩评论

暂无评论...
验证码 换一张
取 消