在Android TV leanback示例中,MainFragment具有导航标题和行。
我可以从MainActity告诉用户当前是在行标题(左侧导航)还是MainFragment的实际行?
public class MainActivity extends LeanbackActivity {
@Override
public void onBackPressed() {
MainFragement mf;
if (mf.focusedOnFragmentHeaders) {
//Do Something
}
}
}
答案 0 :(得分:3)
尝试在BrowseFragment中使用setBrowseTransitionListener
来获取标头过渡状态。
更新
如下!保持withHeaders
setBrowseTransitionListener(new BrowseTransitionListener() {
@Override
public void onHeadersTransitionStart(boolean withHeaders) {
isFocusOnHeader = withHeaders;
}
@Override
public void onHeadersTransitionStop(boolean withHeaders) {
}
});