I am developing app for the google tv and i have to use left navigation bar in my app. I downloaded the google tv examples and am playing with the leftnavbar to make it work as per my requirements. I want it to behave like the one tv & movies OR youtube app for Google TV. It should expand when focus is moved to its tabs by LEFT D-Pad key and collapse when I move focus from it using RIGHT D-Pad key.
I did’t know if there are any properties which will help me achieve this functionality.
So I tried by registering the setOnFocusChangeListener listener and calling flipOption(LeftNavBar.DISPLAY_AUTO_EXPAND) function in it as follows to force it to behave the way i want:
private LeftNavBar getLeftNavBar() {
if (mLeftNavBar == null) {
-------
-------
mLeftNavBar.setOnFocusChangeListener(new View.OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean hasFocus) {
flipOption(LeftNavBar.DISPLAY_AUTO_EXPAND);
}
});
}
return mLeftNavBar;
}
Now the above code works fine when there is nothing in leftNavBar. It shows/hides upon receiving/loosing focus. But it does not work when I add some tabs in it.
Any Idea how to achieve it?
The googletv-android-samples has both the LeftNavBar code and the LeftNavBarDemo. If you use the LeftNavBarDemo, you can see which settings you need to accomplish the behavior your looking for.
It’s just setting the correct options – You really don’t need to flipOption onFocusChange – it will expand and contract automagicly if you set the right initial options. I’d give you specifics, but each application is different.