I\'m new to Android, I\'ve followed the hello world tutorial through and have a basic idea of what\'s going on. I\'m particularly interested in the touch screen of my T-Mob
It sounds like you want to get touch events from the whole area of your layout for this particular test. Try attaching the touch listener to your parent view rather than a separate target view.
This isn't a very common approach. In most cases you will want to listen for touch events in a specific child view and if you have other views in your layout that handle touch events (such as a button) they'll take priority over a parent view. See http://developer.android.com/guide/topics/ui/ui-events.html for more info about handling UI events.
Layout (touch_viewer.xml):
And in your activity:
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.touch_viewer);
final LinearLayout parent = (LinearLayout) findViewById(R.id.parent);
final TextView text = (TextView) findViewById(R.id.text);
parent.setOnTouchListener(new OnTouchListener() {
public boolean onTouch(View v, MotionEvent ev) {
text.setText("Touch at " + ev.getX() + ", " + ev.getY());
return true;
}
});
}