button.setOnTouchListener(new OnTouchListener()
{
public void onClick(View v)
{
Toast.makeText(MainActivity.this, \"YOUR TEXT\", 5000).show();
}
});
<
The code
public void onClick(View v)
{
Toast.makeText(MainActivity.this, "YOUR TEXT", 5000).show();
}
is not valid for an onTouchListener. That is why you are getting the error, you should be using
@Override
public void onTouch(View v, MotionEvent e)
{
Toast.makeText(MainActivity.this, "YOUR TEXT", 5000).show();
}
instead if you really want an onTouchListener, although I highly suggest Chiral Code's suggestion of using an onClickListener