取消选择任何轨迹球/触控板选择
题
有没有一种方法可以通过编程方式取消选择/擦除用户在轨迹球/触控板中选择的任何方法?
当我点击活动上的后退按钮时,它落到的活动中有一个按钮,该按钮就像用户使用了轨迹球/垫一样。我不确定上一个活动中选择了什么,但显然是什么。我想在活动完成之前通过编程方式擦除任何选择。
解决方案
浏览 Javadoc供视图 我看到了许多与焦点相关的功能。
void clearFocus(); // drop focus from this view.
View findFocus(); // finds a view that is a child of this view that has focus, if any
View focusSearch(int dir); // finds the next view that can take focus in the given direction
void requestFocus
听上去像 findFocus().clearFocus()
应该解决这个问题(除非Findfocus碰巧返回null)...您只需要对另一个活动的视图进行处理……如果它是您的代码,那就不太难,或者如果没有代码,则不容易。
如果是您的代码,似乎您可以在按钮的OnClickHandler中添加一个clearFocus()。
不隶属于 StackOverflow