我需要一些幫助與我的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