Hi,
I am trying to get touchscreen functionality. I want to perform some
actions based on whether
user touches the screen up or down.
Here is my code for this
public class Sankhyaki extends Activity implements OnTouchListener,
OnKeyListener {
float x = 0, y = 0;
public static final String TAG="Sankhayaki";
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_sankhyaki);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_sankhyaki, menu);
return true;
}
public boolean onTouch(View v, MotionEvent me)
{
x = me.getX();
y = me.getY();
switch ( me.getAction()) {
case MotionEvent.ACTION_DOWN:
System.out.println("\n ACTION DOWN");
Log.i(TAG,"DOWN");
Log.i(TAG, "x = " + x + "y = " + y );
break;
case MotionEvent.ACTION_UP:
System.out.println("\n ACTION UP");
Log.i(TAG, "UP");
Log.i(TAG, "x = " + x + "y = " + y );
break;
case MotionEvent.ACTION_MOVE:
System.out.println("\n ACTION MOVE");
Log.i(TAG, "MOVE");
Log.i(TAG, "x = " + x + "y = " + y );
break;
}
return false;
}
}
While running it on Emulator, When I click on the screen I
dont see any message in the LogCat or Console. I am not sure if I am doing
any thing wrong.
just because I am not seeing any Log message in Logcat or Console,
it looks like control is not going in the switch case.
There is no way I validate whether I am doing it right or not.
I want to put more code in the switch case only after I am
sure that control goes in the switch case which is not happening here,
Any information would be helpful.
Thanks and Regards,
Vishal
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en