有没有一种方法可以通过编程方式取消选择/擦除用户在轨迹球/触控板中选择的任何方法?

当我点击活动上的后退按钮时,它落到的活动中有一个按钮,该按钮就像用户使用了轨迹球/垫一样。我不确定上一个活动中选择了什么,但显然是什么。我想在活动完成之前通过编程方式擦除任何选择。

有帮助吗?

解决方案

浏览 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()。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top