기술/beginning games2011.05.24 17:20
download download
public class SingleTouchTest extends Activity implements OnTouchListener {

StringBuilder b = new StringBuilder();
TextView textView;

@Override
public void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   textView = new TextView(this);
   textView.setText("터치 또는 드래그를 하세요");
   textView.setOnTouchListener(this);
   setContentView(textView);
 
}

@Override
public boolean onTouch(View v, MotionEvent event) {
b.setLength(0);
switch(event.getAction()){
case MotionEvent.ACTION_DOWN :
b.append("down, ");
break;
case MotionEvent.ACTION_MOVE :
b.append("move, ");
break;
case MotionEvent.ACTION_CANCEL :
b.append("cancel, ");
break;
case MotionEvent.ACTION_UP :
b.append("up, ");
break;
}
b.append(event.getX());
b.append(", ");
b.append(event.getY());
String text = b.toString();
Log.d("터치 테스트", text);
textView.setText(text);
return true;
}

}
저작자 표시
신고
download download download
Posted by [lying dragon] Ed Kim

티스토리 툴바