问题
I'm working with the LeftNavView Libary with Google TV, I have found that I can respond to events when a tab is selected or unselected, but I would like to change an ImageView outside of the tab when Focus has changed (i.e. when using the D-Pad to navigate, but not when it is necessarily selected).
The idea is to change an ImageView in another view when navigating around the tabs. Is there a way to easily do this that I'm not seeing?
回答1:
As there is no way to get the views used for the tabs, i think you will have to extend the LeftNavBarLibrary by implementing some methods either to set a View.OnFocusChangeListener to the ListItemViews (the LeftNavBar uses a ListView for the tabs) or to get the ListItemViews itself and then set the listener. See TabAdapter in TabDisplay.java for this. I did something similar to programmatically set a custom TabBackground by setting a RessourceId to the LeftNavBar, that passes it to the TabDisplay, that passes it to the TabAdapter.
来源:https://stackoverflow.com/questions/14168000/change-imageview-when-tab-focus-changes