2012. 3. 21. 03:01

private OnTouchListener mTouchEvent = new OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {

Button b = (Button)v;
Button Blank = (Button) findViewById(R.id.Blank);

action = event.getAction();
int pureaction = action & MotionEvent.ACTION_MASK;
int pid = (action & MotionEvent.ACTION_POINTER_ID_MASK)
>> MotionEvent.ACTION_POINTER_ID_SHIFT;


if(action == MotionEvent.ACTION_DOWN){
if(t_flag==0){
t_left=b.getLeft();
t_right=b.getRight();
t_top=b.getTop();
t_bottom=b.getBottom();
t_flag=1;
}
}
else if (action == MotionEvent.ACTION_MOVE) {



mResult.setText("bLeft : "+b.getLeft()+"bTop : "+b.getTop()+"__Left : "+(int)event.getRawX()+"Top : "+(int)event.getRawY()+"\n");
b.layout((int)event.getRawX()-40,(int)event.getRawY()-250,(int)event.getRawX()+60,(int)event.getRawY()-150);



} else if (action == MotionEvent.ACTION_UP) {
t_flag=0;
b.layout(t_left,t_top,t_right,t_bottom);
//Toast.makeText(PuzzleActivity.this,"L:"+b.getLeft()+":"+event.getX()+"T"+b.getTop()+":"+event.getY()+"R"+b.getRight()+"B"+((int)event.getX()+100)+":"+b.getBottom()+":"+((int)event.getY()-100),Toast.LENGTH_LONG).show();
//Toast.makeText(PuzzleActivity.this,"L:"+event.getX(0)+"__"+event.getY(0),Toast.LENGTH_LONG).show();

On_Click.허용되지않은 태그 사용중(b);

// b.setBackgroundResource(R.drawable.backimg2);
//System.out.println("x=" + event.getX() + " y=" + event.getY());
}
return true;
}
};

Posted by k1rha