im trying to create a toast with a message that displays the coordinates depending where the user clicks on the screen. when i declare 'mContext=this' i get an error: incompatible types required: Context.
@Override public boolean onTouchEvent(MotionEvent event) { //motionevent detects motion from the user float x; x = event.getX(); float y; y = event.getY(); Context mContext; switch (event.getAction()) { case MotionEvent.ACTION_UP:
//touch_up(x, y);
mContext= this;
float Cox = event.getRawX();
float Coy = event.getRawY();
String text = "You clicked at x = " + Cox+ "and y =" + Coy;
//AlertDialog.Builder builder = new AlertDialog.Builder();
Toast.makeText(mContext, text, Toast.LENGTH_SHORT).show();
//toast.show();
invalidate();
break;
}
return true;
}