Leanback 库 - PlaybackSupportFragment - 如何隐藏次要操作

Leanback library - PlaybackSupportFragment - how to hide secondary actions

我正在开发一个 Android 播放视频的电视应用,我正在使用 PlaybackSupportFragment 来实现屏幕控件。 但是,我无法完全隐藏次要操作(竖起大拇指、不竖起大拇指、重复……)。实际上我能够隐藏按钮,但是 "three dots" 按钮仍然保留在那里。我还没有想出如何隐藏这个 "three dots" 按钮。

我尽量不添加任何辅助操作按钮。但没有运气。没有辅助按钮,但 "three-dots" 按钮仍然存在。

public class MySupportFragment extends PlaybackSupportFragment {
  MyPlaybackControlGlue myGlue = new MyPlaybackControlGlue(context);
  ...
  myGlue.setHost(new PlaybackSupportFragmentGlueHost(this));
  ...
}

public class MyPlaybackControlGlue extends PlaybackControlGlue{
  ...
  @Override
  protected void onCreateSecondaryActions(ArrayObjectAdapter adapter) {
    //Do not add any secondary actions to the adapter
  }
  @Override
  protected void onCreatePrimaryActions(SparseArrayObjectAdapter adapter) {
        //No need to add any other actions here. The Play/Pause action is enough.
  }
}

我想我明白了。 不要在 "onCreateSecondaryActions" 方法中添加任何辅助操作。 但也调用以下方法,以便不显示 "three dots" 按钮。 getControlsRowPresenter().setSecondaryActionsHidden(false)

比如像这样

@Override
protected  void onCreateControlsRowAndPresenter() {
    super.onCreateControlsRowAndPresenter();
    getControlsRowPresenter().setSecondaryActionsHidden(false);
}

您在问题中发布的代码对我有用,但我正在扩展 VideoPlayerGlue

public class CustomPlaybackControlGlue extends VideoPlayerGlue {
    public CustomPlaybackControlGlue(Context context, LeanbackPlayerAdapter playerAdapter, OnActionClickedListener actionListener) {
        super(context, playerAdapter, actionListener);
    }
    @Override
    protected void onCreatePrimaryActions(ArrayObjectAdapter adapter) {
        //Do not add any secondary actions to the adapter
    }
    @Override
    protected void onCreateSecondaryActions(ArrayObjectAdapter adapter) {
        //No need to add any other actions here. The Play/Pause action is enough.
    }
}