android.widget.ListView.getHeaderViewsCount()方法的使用及代码示例

x33g5p2x  于2022-01-23 转载在 其他  
字(8.8k)|赞(0)|评价(0)|浏览(172)

本文整理了Java中android.widget.ListView.getHeaderViewsCount()方法的一些代码示例,展示了ListView.getHeaderViewsCount()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ListView.getHeaderViewsCount()方法的具体详情如下:
包路径:android.widget.ListView
类名称:ListView
方法名:getHeaderViewsCount

ListView.getHeaderViewsCount介绍

暂无

代码示例

代码示例来源:origin: square/assertj-android

public S hasHeaderViewsCount(int count) {
 isNotNull();
 int actualCount = actual.getHeaderViewsCount();
 assertThat(actualCount) //
   .overridingErrorMessage("Expected header views count <%s> but was <%s>.", count, actualCount) //
   .isEqualTo(count);
 return myself;
}

代码示例来源:origin: wangdan/AisenWeiBo

@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
  position = position - ((ListView) getRefreshView()).getHeaderViewsCount();
  FriendMentionDB.addFriend(getAdapterItems().get(position));
  Intent data = new Intent();
  data.putExtra("bean", getAdapterItems().get(position));
  getActivity().setResult(Activity.RESULT_OK, data);
  getActivity().finish();
}

代码示例来源:origin: wangdan/AisenWeiBo

public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
  int header = getRefreshView().getHeaderViewsCount();
  ProfilePagerFragment.launch(getActivity(), getAdapterItems().get(position - header));
}

代码示例来源:origin: robolectric/robolectric

@Test
public void addHeaderView_ShouldRecordHeaders() throws Exception {
 View view0 = new View(context);
 view0.setId(0);
 View view1 = new View(context);
 view1.setId(1);
 View view2 = new View(context);
 view2.setId(2);
 View view3 = new View(context);
 view3.setId(3);
 listView.addHeaderView(view0);
 listView.addHeaderView(view1);
 listView.addHeaderView(view2, null, false);
 listView.addHeaderView(view3, null, false);
 listView.setAdapter(new ShadowCountingAdapter(2));
 assertThat(listView.getHeaderViewsCount()).isEqualTo(4);
 assertThat(shadowOf(listView).getHeaderViews().get(0)).isSameAs(view0);
 assertThat(shadowOf(listView).getHeaderViews().get(1)).isSameAs(view1);
 assertThat(shadowOf(listView).getHeaderViews().get(2)).isSameAs(view2);
 assertThat(shadowOf(listView).getHeaderViews().get(3)).isSameAs(view3);
 assertThat((View) listView.findViewById(0)).isNotNull();
 assertThat((View) listView.findViewById(1)).isNotNull();
 assertThat((View) listView.findViewById(2)).isNotNull();
 assertThat((View) listView.findViewById(3)).isNotNull();
}

代码示例来源:origin: waynell/VideoListPlayer

@SuppressWarnings("unchecked")
@Override
public View getView(int position, View convertView, ViewGroup parent) {
  BaseViewHolder holder;
  if (convertView == null) {
    holder = ViewHolderFactory.buildViewHolder(parent, getItemViewType(position));
    convertView = holder.itemView;
    convertView.setTag(holder);
  }
  else {
    holder = (BaseViewHolder) convertView.getTag();
  }
  holder.onBind(position, getItem(position));
  // record holder's position, must add ListView header's count
  mHolderHelper.put(holder, position + mListView.getHeaderViewsCount());
  return convertView;
}

代码示例来源:origin: andforce/iBeebo

private ViewHolder getViewHolderByView(int position) {
  int wantedPosition = position - listView.getHeaderViewsCount();
  int firstPosition = listView.getFirstVisiblePosition() - listView.getHeaderViewsCount();
  int wantedChild = wantedPosition - firstPosition;
  if (wantedChild < 0 || wantedChild >= listView.getChildCount()) {
    return null;
  }
  View wantedView = listView.getChildAt(wantedChild);
  ViewHolder holder = (ViewHolder) wantedView.getTag();
  return holder;
}

代码示例来源:origin: smuyyh/SprintNBA

@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
  if (position < mListView.getHeaderViewsCount()) return;
  Object object = mAdapter.getItem(position - mListView.getHeaderViewsCount());
  if (mOnTitleListener != null && object instanceof String) {
    String title = (String) object;
    mOnTitleListener.onItemClick(view, title);
  } else if (mOnContentListener != null && object instanceof IndexEntity) {
    IndexEntity indexEntity = (IndexEntity) object;
    mOnContentListener.onItemClick(view, indexEntity);
  }
}

代码示例来源:origin: com.squareup.assertj/assertj-android

public S hasHeaderViewsCount(int count) {
 isNotNull();
 int actualCount = actual.getHeaderViewsCount();
 assertThat(actualCount) //
   .overridingErrorMessage("Expected header views count <%s> but was <%s>.", count, actualCount) //
   .isEqualTo(count);
 return myself;
}

代码示例来源:origin: andforce/iBeebo

private ViewHolder getViewHolderByView(int position) {
  int wantedPosition = position - listView.getHeaderViewsCount();
  int firstPosition = listView.getFirstVisiblePosition() - listView.getHeaderViewsCount();
  int wantedChild = wantedPosition - firstPosition;
  if (wantedChild < 0 || wantedChild >= listView.getChildCount()) {
    return null;
  }
  View wantedView = listView.getChildAt(wantedChild);
  ViewHolder holder = (ViewHolder) wantedView.getTag(R.string.app_name + getItemViewType(wantedPosition));
  return holder;
}

代码示例来源:origin: smuyyh/SprintNBA

private void processStick(int firstVisibleItem, int totalItemCount) {
  if (firstVisibleItem < totalItemCount - 1 && mTitleMap.get(firstVisibleItem - mListView.getHeaderViewsCount() + 1) != null) {
    int nextTop = mListView.getChildAt(1).getTop();
    if (nextTop <= mTitleHeight) {
      if (mStickView.getVisibility() != VISIBLE) {
        if (mAdapter == null || !mAdapter.isFilter()) {
          mStickView.setVisibility(VISIBLE);
        }
      }
      mStickView.setTranslationY(nextTop - mTitleHeight);
    }
  }
}

代码示例来源:origin: andforce/iBeebo

@Override
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
  View childView = Utility.getListViewItemViewFromPosition(listView, firstVisibleItem);
  if (childView == null) {
    return;
  }
  int position = firstVisibleItem - ((ListView) view).getHeaderViewsCount();
  if (childView.getTop() == 0 && position <= 0) {
    topTipBar.clearAndReset();
  } else {
    handle(position + 1);
  }
}

代码示例来源:origin: sealtalk/sealtalk-android

public void onEventMainThread(UserInfo userInfo) {
  if (mList != null) {
    int first = mList.getFirstVisiblePosition() - mList.getHeaderViewsCount();
    int last = mList.getLastVisiblePosition() - mList.getHeaderViewsCount();
    int index = first - 1;
    while (++index <= last && index >= 0 && index < mAdapter.getCount()) {
      if (mAdapter.getItem(index).equals(userInfo.getUserId())) {
        mAdapter.getView(index, mList.getChildAt(index - mList.getFirstVisiblePosition() + mList.getHeaderViewsCount()), mList);
      }
    }
  }
}

代码示例来源:origin: andforce/iBeebo

@Override
  public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
    getListView().clearChoices();
    if (position - listView.getHeaderViewsCount() >= commentList.getSize()) {
      loadOldCommentData();
    }
  }
};

代码示例来源:origin: skydoves/PowerMenu

@Override
  public void onClick(View view) {
    listView.getOnItemClickListener()
        .onItemClick(
            listView,
            view,
            index + listView.getHeaderViewsCount(),
            getItemId(index));
  }
});

代码示例来源:origin: andforce/iBeebo

@Override
  public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
    getListView().clearChoices();
    if (position - listView.getHeaderViewsCount() < repostList.getSize()
        && position >= listView.getHeaderViewsCount()) {
      startActivity(BrowserWeiboMsgActivity.newIntent(BeeboApplication.getInstance().getAccountBean(),
          repostList.getItemList().get(position - listView.getHeaderViewsCount()), BeeboApplication.getInstance()
              .getAccessTokenHack()));
    } else {
      loadOldRepostData();
    }
  }
};

代码示例来源:origin: andforce/iBeebo

private DMViewHolder getViewHolderByView(int position) {

    int wantedPosition = position - 1;
    int firstPosition = listView.getFirstVisiblePosition() - listView.getHeaderViewsCount();
    int wantedChild = wantedPosition - firstPosition;

    if (wantedChild < 0 || wantedChild >= listView.getChildCount()) {
      return null;
    }

    View wantedView = listView.getChildAt(wantedChild);
    DMViewHolder holder = (DMViewHolder) wantedView.getTag(R.string.app_name + getItemViewType(position));
    return holder;

  }
}

代码示例来源:origin: Coinomi/coinomi-android

@Override
  public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
    if (position >= outputRows.getHeaderViewsCount()) {
      Object obj = parent.getItemAtPosition(position);
      if (obj != null && obj instanceof AbstractOutput) {
        UiUtils.startAddressActionMode(((AbstractOutput) obj).getAddress(),
            getActivity(), getFragmentManager());
      }
    }
  }
};

代码示例来源:origin: andforce/iBeebo

@Override
  public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
    if (getListView().getLastVisiblePosition() > 7
        && getListView().getFirstVisiblePosition() != getListView().getHeaderViewsCount()) {
      if (getListView().getLastVisiblePosition() > repostList.size() - 3) {
        loadOldRepostData();
      }
    }
  }
};

代码示例来源:origin: andstatus/andstatus

@Override
  public void run() {
    final String msg = "goToPosition " + position;
    MyLog.v(methodExt, msg);
    try {
      listView.setSelectionFromTop(position + listView.getHeaderViewsCount(), 0);
    } catch (Exception e) {
      MyLog.e(msg, e);
    }
  }
});

代码示例来源:origin: andforce/iBeebo

@Override
  public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
    if (getListView().getLastVisiblePosition() > 7
        && getListView().getLastVisiblePosition() > getList().getUsers().size() - 3
        && getListView().getFirstVisiblePosition() != getListView().getHeaderViewsCount()) {
      loadOldMsg(null);
    }
  }
}

相关文章

ListView类方法