我需要一些帮助与我的android程序。我需要在每次触摸时出现几个TextView。 1st touch = TextView1,2nd touch = TextView2等。我试图在ACTION_DOWN之后用ACTION_POINTER_DOWN做它,但它在一次触摸中显示所有文本视图。Android开发:第一个触摸= TextView1,第二个触摸= TextView2等
public boolean onTouch(View v, MotionEvent event) {
boolean inTouch = false;
int actionMask = event.getActionMasked();
tv = (TextView) findViewById(R.id.textView3);
tv1 = (TextView) findViewById(R.id.textView4);
tv2 = (TextView) findViewById(R.id.textView5);
tv3 = (TextView) findViewById(R.id.textView6);
int pointerCount = event.getPointerCount();
int downPI = 0;
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN: // 1st touch
inTouch = true;
case MotionEvent.ACTION_POINTER_DOWN: // next touches
downPI = pointerCount;
switch (downPI) {
case 0:
tv.setVisibility(View.VISIBLE);
break;
case 1:
tv1.setVisibility(View.VISIBLE);
break;
case 2:
tv2.setVisibility(View.VISIBLE);
break;
case 3:
tv3.setVisibility(View.VISIBLE);
break;
}
break;
}
return false;
您在'ACTION_UP'检查,因为'ACTION_DOWN'被触发经常 – Denny