开发者

move the image according to trackball

开发者 https://www.devze.com 2023-01-22 13:13 出处:网络
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 advanceHaven\'t done anything exactly like

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;
}
0

精彩评论

暂无评论...
验证码 换一张
取 消