tags:

views:

23

answers:

1

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

+1  A: 

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;
}
Dave
but that onkeyDown method is worked in an activity ,But i want to use this in canvas class
sairamu
Have a look at this link, You still must be using an activity so this will show you how to push your activity events to the canvas view.. http://www.anddev.org/rotating_3d-objects_based_on_keyevents-t51.html
Dave