林现在正在寻找2周,但没有成功的解决方案。 这个问题很简单。我模拟了DPAD事件(上,下,左,右,中心)进行导航在我的GUI这就是由大量的按钮和其他元素。随着模拟D-垫我可以不带线code浏览抛出这个GUI。但是,我怎么能做到这一点编程?
Im searching now for 2 weeks for a solution with no success. The problem is very simple. I have to simulate the dpad events (UP,DOWN,RIGHT,LEFT,CENTER) for navigate in my GUI thats consist of a lot of buttons and other elements. With the simulator D-Pad i can without a line code navigate throw this GUI. But how can i do this programmatically?
我已经尝试了很多,但没有成功:
I have tried a lot with no success:
KeyEvent的事件=新的KeyEvent(KeyEvent.ACTION_DOWN,KeyEvent.KEY code_DPAD_LEFT);
View.dispatchKeyEvent(事件);
没有发生(重点应该转移的一个元素右)
KeyEvent event = new KeyEvent(KeyEvent.ACTION_DOWN,KeyEvent.KEYCODE_DPAD_LEFT);
View.dispatchKeyEvent(event);
Nothing happen (the focus should move one element to right)
我也看到了很多关于windowManager.injectKeyEvent,但没有找到工作的。
I have also read a lot about windowManager.injectKeyEvent but nothing found that works.
我觉得有一个解决方案,因为对讲系统可以模拟物理方向键(http://$c$c.google.com/p/eyes-free/source/browse/trunk/ime/latinime/src/com/google$c$c/eyesfree/inputmethod/latin/LatinIME.java)
I think there is a solution, because talkback can simulate the physical D-Pad (http://code.google.com/p/eyes-free/source/browse/trunk/ime/latinime/src/com/googlecode/eyesfree/inputmethod/latin/LatinIME.java)
我需要帮助:-( THX
I need help :-( Thx
我找到了聪明的解决方案(例如下去):
I found the smart solution (e.g for go down):
bic=new BaseInputConnection(this.getWindow().getDecorView(),false);
KeyEvent event2 = new KeyEvent(0, 0, KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_DPAD_DOWN,0, KeyEvent.META_SYM_ON, 0, 0, KeyEvent.FLAG_VIRTUAL_HARD_KEY);
bic.sendKeyEvent(event2);
这就是所有,内部algortihm发现在你选择的方向下一个元素
Thats all, an internal algortihm find the next element in your selected direction