androidtrackball

Android - Prevent UI elements from being selected by trackball


So I have a Player view with seekbar and play/pause/rewind, etc. buttons, which are ImageButtons that have pressed and normal states, but no selected states.

Given that there are a number of android devices that have a trackball as alternate input (aside from the touchscreen), is there any way for me to prevent the trackball from focusing some of my UI elements? Thing is, i want the trackball to be used solely for the seekbar, but I don't want the user to be able to scroll down/up to focus on the other buttons.

I tried setting focusable=false on the elements i don't want to get focus, but it doesn't work.

Is this even possible?


Solution

  • Tryusing

    seekbar.requestFocus();
    seekbar.setNextFocusUpId(seekbarid);
    seekbar.setNextFocusDownId(seekbarid);
    seekbar.setNextFocusLeftId(seekbarid);
    seekbar.setNextFocusRightId(seekbarid);
    

    This way the seekbar should always regains the focus even when trackball moves.