




public class AndroidsCastleActivity extends Activity{
private TextView textView;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
textView = (TextView)findViewById(R.id.textView1);
}
@Override
public boolean onTouchEvent(MotionEvent e) {
textView.setText( "X:" + e.getX() + "\nY:" + e.getY() );
switch (e.getAction()) {
case MotionEvent.ACTION_DOWN:
Log.d("Sample", "ACTION_DOWN");
break;
case MotionEvent.ACTION_UP:
Log.d("Sample", "ACTION_UP");
break;
case MotionEvent.ACTION_MOVE:
Log.d("Sample", "ACTION_MOVE");
break;
}
return true;
}
}
| ACTION_DOWN | 押した |
| ACTION_MOVE | 押したままスライド |
| ACTION_UP | 離した |
| ACTION_CANCEL | UPとDOWNの同時発生 |
| getX(),getY() | 押された座標 |
| getAction() | アクションの種類 |
| getDownTime() | 押されている時間[ms] |
| getEdgeFlags() | 押した位置が画面端か |
| getEventTime() | タッチされていた継続時間(ms単位) |
| getPressure() | タッチされた圧力 |
Portions of this page are modifications
based on work created and shared by Google and used according to terms
described in the Creative Commons 3.0 Attribution License.
- Remical Soft -