@Override public int getCount() { if (isHaveMore) { return mAdapter.getCount() + 1; } else { return mAdapter.getCount(); } }
public static void setListViewHeight(ListView mListView, BaseAdapter adapter) { adapter = (BaseAdapter) mListView.getAdapter(); if (adapter == null) { return; } int mTotalHeight = 0; for (int i = 0; i < adapter.getCount(); i++) { View mListItem = adapter.getView(i, null, mListView); mListItem.measure(0, 0); mTotalHeight += mListItem.getMeasuredHeight(); } ViewGroup.LayoutParams mParams = mListView.getLayoutParams(); mParams.height = mTotalHeight + (mListView.getDividerHeight() * (adapter.getCount() - 1)); mListView.setLayoutParams(mParams); }
public void fillLinearLayout() { removeAllViews(); if (mHeaderView != null) { addView(mHeaderView); } int count = mAdapter.getCount(); if (mCacheView.size() != count) { // TODO 全部清掉太粗暴了 mCacheView.clear(); } for (int i = 0; i < count; i++) { View srcView = null; if (mCacheView.size() > i) { srcView = mCacheView.get(i); } View v = mAdapter.getView(i, srcView, null); if (mCacheView.size() > i) { mCacheView.set(i, v); } else { mCacheView.add(v); } v.setOnClickListener(this.onClickListener); addView(v); } if (mFooterView != null) { addView(mFooterView); } }
public boolean isNewData() { int dataSize = ((MainActivity) getActivity()).model.getRestaurantByLocation(selectLocation).size(); if (dataSize > mAdapter.getCount()) { return true; } return false; }
public boolean hasItemSelected() { int count = mAdapter.getCount(); for (int i = 0; i < count; i++) { RecordItem item = mRecordItemList.get(i); if (item != null && item.isSelected) { return true; } } return false; }
public int getSelectedItemCount() { int count = 0; int len = mAdapter.getCount(); for (int i = 0; i < len; i++) { RecordItem item = mRecordItemList.get(i); if (item != null && item.isSelected) { count++; } } return count; }
public void unselectAllItem() { if (!hasItemSelected()) { return; } setNotificationsEnabled(false); int count = mAdapter.getCount(); for (int i = 0; i < count; i++) { setItemSelected(i, false); } setNotificationsEnabled(true); notifyDataSetChanged(); }
public static void setListViewHeightBasedOnChildren(ListView listView, BaseAdapter adapter) { // 获取ListView对应的Adapter if (adapter == null) { return; } int totalHeight = 0; for (int i = 0, len = adapter.getCount(); i < len; i++) { // listAdapter.getCount()返回数据项的数目 View listItem = adapter.getView(i, null, listView); // 计算子项View 的宽高 listItem.measure(0, 0); // 统计所有子项的总高度 totalHeight += listItem.getMeasuredHeight(); } ViewGroup.LayoutParams params = listView.getLayoutParams(); params.height = totalHeight + (listView.getDividerHeight() * (adapter.getCount() - 1)); // listView.getDividerHeight()获取子项间分隔符占用的高度 // params.height最后得到整个ListView完整显示需要的高度 listView.setLayoutParams(params); }
private void populateWallpapersFromAdapter( ViewGroup parent, BaseAdapter adapter, boolean addLongPressHandler) { for (int i = 0; i < adapter.getCount(); i++) { FrameLayout thumbnail = (FrameLayout) adapter.getView(i, null, parent); parent.addView(thumbnail, i); WallpaperTileInfo info = (WallpaperTileInfo) adapter.getItem(i); thumbnail.setTag(info); info.setView(thumbnail); if (addLongPressHandler) { addLongPressHandler(thumbnail); } thumbnail.setOnClickListener(mThumbnailOnClickListener); } }
private void init() { int count = mAdapter.getCount(); for (int i = 0; i < count; i++) { IRecord record = (IRecord) mAdapter.getItem(i); // 过滤掉分隔线 if (record == null) { mRecordItemList.add(null); continue; } RecordItem item = new RecordItem(); item.record = (IRecord) mAdapter.getItem(i); item.isSelected = isRecordSelectable((RestorableRecord) item.record); mRecordItemList.add(item); } }
public boolean shouleMergeRecord() { int count = mAdapter.getCount(); int isSelectedCount = 0; for (int i = 0; i < count; i++) { RecordItem item = mRecordItemList.get(i); if (item != null && item.isSelected) { isSelectedCount++; } } if (mSmartMergedRecord != null) { isSelectedCount++; } if (isSelectedCount > 1) { return true; } return false; }
/** {@inheritDoc} */ public Object getItem(int pos) { for (Object section : mSections.keySet()) { BaseAdapter adapter = mSections.get(section); int size = adapter.getCount() + 1; if (pos == 0) { return section; } if (pos < size) { return adapter.getItem(pos - 1); } pos -= size; } return null; }
/** {@inheritDoc} */ public View getView(int pos, View convertView, ViewGroup parent) { int sectionNum = 0; for (Object section : mSections.keySet()) { BaseAdapter adapter = mSections.get(section); int size = adapter.getCount() + 1; if (pos == 0) { return mHeaderAdapter.getView(sectionNum, null, parent); } if (pos < size) { return adapter.getView(pos - 1, null, parent); } pos -= size; sectionNum++; } return null; }
public int getCount() { return adapter == null ? 0 : adapter.getCount(); }
@Override public int getCount() { return mDecoratedBaseAdapter.getCount(); }
@Override public int getCount() { return mAdapter.getCount(); }
@Override public int getCount() { return mWrappedBase.getCount(); }