Im using seek bar to control volume of the device. Im able to change the volume of the device using thumb of the seek bar just by dragging it on touch pad.
But when
I got solution, by overriding onkeydown event.
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_VOLUME_UP)
{
int index = seekbar.getProgress();
seekbar.setProgress(index + 1);
return true;
} else if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN)
{
int index = seekbar.getProgress();
seekbar.setProgress(index - 1);
return true;
}
return super.onKeyDown(keyCode, event);
}
Edited for further reference