我使用ontouch事件,但問題IM有就是它召喚事件,但它是NT調用move事件或UP事件 檢查下面的代碼的Android onTouch監聽事件
public class DragNewActivity extends Activity implements OnTouchListener {
private float X;
private float Y;
private int width;
private int height;
private CharSequence s;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Log.d("D","D");
TextView tv1 = (TextView)findViewById(R.id.tv1);
TextView tv2 = (TextView)findViewById(R.id.tv2);
tv1.setOnTouchListener(this);
//tv2.setOnTouchListener(this);
}
@Override
public boolean onTouch(View v, MotionEvent event) {
//int action = event.getAction();
switch (event.getAction()){
case MotionEvent.ACTION_DOWN:
Log.d("DOWN","DOWN");
break;
case MotionEvent.ACTION_MOVE:
Log.d("MOVE","MOVE");
break;
case MotionEvent.ACTION_UP:
Log.d("UP","UP");
X = event.getRawX();
Y = event.getRawY();
Display display = getWindowManager().getDefaultDisplay();
width=display.getWidth()/2;
height=display.getHeight()/2;
Log.e("X", X+"");
Log.e("Y", Y+"");
Log.e("ScX", width+"");
Log.e("ScY", height+"");
if(X>width && Y>height){
Log.e("SUFI", "Event ho gyuaaaaaaa");
}
break;
}
return false;
}
}