onKeyDown method on Android emulator is not working for physical keyboard DPAD -
i have custom view has below method. client view loads sudoku board. want implement cursor on board allow motion of selected square box when user select physical keyboard dpad. below method have cursor implementation.
my issue when press of dpads physical keyboard, nil happens on sudoku board. seems not able observe dpad physical keyboard.
public boolean onkeydown(int keycode, keyevent event) { log.d(tag, "onkeydown: keycode=" + keycode + ", event=" + event); switch (keycode) { case keyevent.keycode_1: select(selx, sely - 1); break; case keyevent.keycode_dpad_down: select(selx, sely + 1); break; case keyevent.keycode_dpad_left: select(selx - 1, sely); break; case keyevent.keycode_dpad_right: select(selx + 1, sely); break; default: homecoming super.onkeydown(keycode, event); } homecoming true; } private void select(int x, int y) { invalidate(selrect); selx = math.min(math.max(x, 0), 8); sely = math.min(math.max(y, 0), 8); getrect(selx, sely, selrect); invalidate(selrect); }
i have fixed issue . below resolution steps :
a) add together setfocusable(true) , setfocusableintouchmode(true) constructor of custom view
b) enable keyboard emulator in avd config file.
android
No comments:
Post a Comment