setOnTouchListener() is giving me an error

前端 未结 7 521
北恋
北恋 2021-01-27 18:25
button.setOnTouchListener(new OnTouchListener()
{
  public void onClick(View v)
  {
      Toast.makeText(MainActivity.this, \"YOUR TEXT\", 5000).show();
  }
});
<         


        
7条回答
  •  借酒劲吻你
    2021-01-27 19:08

    you are putting an ontouchlistener with an onclick listener thats your mistake.

        button.setOnTouchListener(new OnTouchListener(){
    
            @Override
            public boolean onTouch(View v, MotionEvent event) {
    
         Toast.makeText(MainActivity.this, "YOUR TEXT", 5000).show();
        return false;
        }
     });
    

提交回复
热议问题