【问题标题】:Leanback library - PlaybackSupportFragment - how to hide secondary actionsLeanback 库 - PlaybackSupportFragment - 如何隐藏辅助操作
【发布时间】:2019-08-11 21:00:42
【问题描述】:

我正在开发一个播放视频的 Android TV 应用,并且我正在使用 PlaybackSupportFragment 来实现屏幕控件。 但是,我无法完全隐藏次要操作(竖起大拇指、向下竖起大拇指、重复……)。实际上我可以隐藏按钮,但是“三个点”按钮仍然留在那里。而且我还没有弄清楚如何隐藏这个“三个点”按钮。

我尝试不添加任何辅助操作按钮。但没有运气。没有辅助按钮,但“三点”按钮仍然存在。

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.
  }
}

【问题讨论】:

    标签: java android android-tv leanback


    【解决方案1】:

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

    比如这样

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

    【讨论】:

      【解决方案2】:

      您在问题中发布的代码对我有用,但是我正在扩展 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.
          }
      }
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2012-02-05
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-02-14
        相关资源
        最近更新 更多