今天在处理自定义的View的时候,本想实现接收到touch事件后设定View获取焦点,从而接收按键事件,不过总是不成功,
后来发现view里面是除了
以外,还有一个
这个函数的描述如下:
Set whether this view can receive focus while in touch mode. Setting this to true will also ensure that this view is focusable.
看样子Android对TouchMode下的焦点获取采取了特殊的对待,在View初始化时加上setFocusableInTouchMode(true),OnTouch中的requestFocus()就起效了。