Skip to content

主页默认选中页面,tab未显示默认选中项 #5

@hardlove

Description

@hardlove

如图:
``
image

调试时发现:
View positionView = horizontalGridView.getChildAt(Constants.TAG_FEATURE_POSITION);获取到的positionView 为null;
不知道为什么会为null,有点奇怪,不知道作者有发现没有。
image

我是这么处理的,可以解决问题

  //延时一会儿,否则positionView获取为null
  postDelayed(new Runnable() {
      @Override
      public void run() {
          horizontalGridView.setSelectedPositionSmooth(Constants.TAG_FEATURE_POSITION);
          View positionView = horizontalGridView.getChildAt(Constants.TAG_FEATURE_POSITION);
          if (positionView != null) {
              activity.mOldTitle = positionView.findViewById(R.id.tv_main_title);
              positionView.requestFocus();
          }
      }
  }, 0);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions