Android TV leanback。如何判断用户是否在MainActivity的标题导航中?

时间:2017-04-14 00:54:15

标签: android android-tv leanback

在Android TV leanback示例中,MainFragment具有导航标题和行。

我可以从MainActity告诉用户当前是在行标题(左侧导航)还是MainFragment的实际行?

public class MainActivity extends LeanbackActivity {

    @Override
    public void onBackPressed() {

        MainFragement mf;                 

        if (mf.focusedOnFragmentHeaders) {
            //Do Something
        }
    } 
}

enter image description here

1 个答案:

答案 0 :(得分:3)

尝试在BrowseFragment中使用setBrowseTransitionListener来获取标头过渡状态。

更新

如下!保持withHeaders

setBrowseTransitionListener(new BrowseTransitionListener() {
   @Override
   public void onHeadersTransitionStart(boolean withHeaders) {
       isFocusOnHeader = withHeaders;
   }

   @Override
   public void onHeadersTransitionStop(boolean withHeaders) {
   }
});