Hi i want to 开发者_开发百科move the image left right,down,up directions according to track ball .for this please give me the some code suggestions.Thanks in advance
Haven't done anything exactly like that before, but I certainly have detected trackball presses for some of my projects, to detect up,down,left right is very similar, so you just need to move your image on the event.. Hope this is of use:
public boolean onKeyDown(int keyCode, KeyEvent event) {
switch (keyCode) {
case KeyEvent.KEYCODE_DPAD_UP :
// code to move image up
break;
case KeyEvent.KEYCODE_DPAD_DOWN :
// code to move image down
break;
case KeyEvent.KEYCODE_DPAD_LEFT :
// code to move image left
break;
case KeyEvent.KEYCODE_DPAD_RIGHT :
// code to move image right
break;
}
return false;
}
精彩评论