Can't handle both click and touch events simultaneously

后端 未结 12 2069
时光说笑
时光说笑 2020-12-01 03:45

I am trying to handle touch events and click events on a button. I do the following:

button.setOnClickListener(clickListener);
button.setOnTouchListener(touc         


        
12条回答
  •  一个人的身影
    2020-12-01 04:01

    To make both events possible in gridview,only by making return of touch listener"false" as follows,this worked for me.

    **GridView myView = findViewById(R.id.grid_view);
    myView.setOnTouchListener(new OnTouchListener() {
        public boolean onTouch(View v, MotionEvent event) {
            // ... Respond to touch events
            return false;
        }
    });**
    

    in this way both events can be achieved

提交回复
热议问题