1:程序在UI的界面中,显示当前的MotionEvent的动作和位置。
2:触摸屏主要通过实现以下函数来接收:
public boolean onTouchEvent(MotionEvent event)
/**
* 初始化资源文件
*
* @param
* @return void
* @throws
* @since TianTian
*/
private void initResource()
{
touch_value1 = (TextView) findViewById(R.id.touch_value1);
touch_value2 = (TextView) findViewById(R.id.touch_value2);
}
/**
* 触屏控制
*
* @param
* @return void
* @throws
* @since TianTian
*/
@Override
public boolean onTouchEvent(MotionEvent event)
{
int Action = event.getAction(); //0 按下状态 1 抬起状态 2 拖动状态
float X = event.getX();
float Y = event.getY();
touch_value1.setText("Action = "+ Action);
touch_value2.setText("Postion = ("+X+","+Y+")");
return true;
}
2:触摸屏主要通过实现以下函数来接收:
public boolean onTouchEvent(MotionEvent event)
/**
* 初始化资源文件
*
* @param
* @return void
* @throws
* @since TianTian
*/
private void initResource()
{
touch_value1 = (TextView) findViewById(R.id.touch_value1);
touch_value2 = (TextView) findViewById(R.id.touch_value2);
}
/**
* 触屏控制
*
* @param
* @return void
* @throws
* @since TianTian
*/
@Override
public boolean onTouchEvent(MotionEvent event)
{
int Action = event.getAction(); //0 按下状态 1 抬起状态 2 拖动状态
float X = event.getX();
float Y = event.getY();
touch_value1.setText("Action = "+ Action);
touch_value2.setText("Postion = ("+X+","+Y+")");
return true;
}