本文整理了Java中android.widget.ListAdapter.getItemViewType()
方法的一些代码示例,展示了ListAdapter.getItemViewType()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ListAdapter.getItemViewType()
方法的具体详情如下:
包路径:android.widget.ListAdapter
类名称:ListAdapter
方法名:getItemViewType
暂无
代码示例来源:origin: rey5137/material
public int getItemViewType(int position) {
final ListAdapter adapter = mListAdapter;
if (adapter != null)
return adapter.getItemViewType(position);
else
return 0;
}
代码示例来源:origin: chentao0707/SimplifyReader
private boolean isHeaderOrFooterPosition( int pos ){
int type = mAdapter.getItemViewType(pos);
return type == ITEM_VIEW_TYPE_HEADER_OR_FOOTER;
}
代码示例来源:origin: chentao0707/SimplifyReader
@Override
public int getItemViewType(int position) {
if (mAdapter != null) {
return mAdapter.getItemViewType(position);
}
return -1;
}
代码示例来源:origin: TonicArtos/StickyGridHeaders
@Override
public int getItemViewType(int position) {
return mDelegate.getItemViewType(position);
}
代码示例来源:origin: chentao0707/SimplifyReader
public int getItemViewType(int position) {
int numHeaders = getHeadersCount();
if (mAdapter != null && position >= numHeaders) {
int adjPosition = position - numHeaders;
int adapterCount = mAdapter.getCount();
if (adjPosition < adapterCount) {
return mAdapter.getItemViewType(adjPosition);
}
}
return PLAAdapterView.ITEM_VIEW_TYPE_HEADER_OR_FOOTER;
}
代码示例来源:origin: commonsguy/cw-omnibus
final int count = adapter.getCount();
for (int i = 0; i < count; i++) {
final int positionType = adapter.getItemViewType(i);
if (positionType != itemType) {
itemType = positionType;
代码示例来源:origin: chentao0707/SimplifyReader
private void measureScrapChild(View child, int position, int widthMeasureSpec) {
LayoutParams p = (LayoutParams) child.getLayoutParams();
if (p == null) {
p = new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT, 0);
child.setLayoutParams(p);
}
p.viewType = mAdapter.getItemViewType(position);
p.forceAdd = true;
int childWidthSpec = ViewGroup.getChildMeasureSpec(widthMeasureSpec,
mListPadding.left + mListPadding.right, p.width);
int lpHeight = p.height;
int childHeightSpec;
if (lpHeight > 0) {
childHeightSpec = MeasureSpec.makeMeasureSpec(lpHeight, MeasureSpec.EXACTLY);
} else {
childHeightSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
}
child.measure(childWidthSpec, childHeightSpec);
}
代码示例来源:origin: chentao0707/SimplifyReader
scrapViews = mCurrentScrap;
} else {
final int whichScrap = mAdapter.getItemViewType(position);
if (whichScrap >= 0 && whichScrap < mScrapViews.length) {
scrapViews = mScrapViews[whichScrap];
代码示例来源:origin: stackoverflow.com
final int count = adapter.getCount();
for (int i = 0; i < count; i++) {
final int positionType = adapter.getItemViewType(i);
if (positionType != itemType) {
itemType = positionType;
代码示例来源:origin: arimorty/floatingsearchview
private int measureContentWidth() {
// Menus don't tend to be long, so this is more sane than it looks.
int maxWidth = 0;
View itemView = null;
int itemType = 0;
final ListAdapter adapter = mAdapter;
final int widthMeasureSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
final int heightMeasureSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
final int count = adapter.getCount();
for (int i = 0; i < count; i++) {
final int positionType = adapter.getItemViewType(i);
if (positionType != itemType) {
itemType = positionType;
itemView = null;
}
if (mMeasureParent == null) {
mMeasureParent = new FrameLayout(mContext);
}
itemView = adapter.getView(i, itemView, mMeasureParent);
itemView.measure(widthMeasureSpec, heightMeasureSpec);
final int itemWidth = itemView.getMeasuredWidth();
if (itemWidth >= mPopupMaxWidth) {
return mPopupMaxWidth;
} else if (itemWidth > maxWidth) {
maxWidth = itemWidth;
}
}
return maxWidth;
}
@Override
代码示例来源:origin: beworker/pinned-section-listview
int findFirstVisibleSectionPosition(int firstVisibleItem, int visibleItemCount) {
ListAdapter adapter = getAdapter();
int adapterDataCount = adapter.getCount();
if (getLastVisiblePosition() >= adapterDataCount) return -1; // dataset has changed, no candidate
if (firstVisibleItem+visibleItemCount >= adapterDataCount){//added to prevent index Outofbound (in case)
visibleItemCount = adapterDataCount-firstVisibleItem;
}
for (int childIndex = 0; childIndex < visibleItemCount; childIndex++) {
int position = firstVisibleItem + childIndex;
int viewType = adapter.getItemViewType(position);
if (isItemViewTypePinned(adapter, viewType)) return position;
}
return -1;
}
代码示例来源:origin: ksoichiro/Android-ObservableScrollView
if (adjPosition >= 0 && adjPosition < adapterCount) {
if (adjPosition < mAdapter.getCount()) {
type = mAdapter.getItemViewType(adjPosition);
} else {
if (mCachePlaceHoldView) {
代码示例来源:origin: beworker/pinned-section-listview
int findCurrentSectionPosition(int fromPosition) {
ListAdapter adapter = getAdapter();
if (fromPosition >= adapter.getCount()) return -1; // dataset has changed, no candidate
if (adapter instanceof SectionIndexer) {
// try fast way by asking section indexer
SectionIndexer indexer = (SectionIndexer) adapter;
int sectionPosition = indexer.getSectionForPosition(fromPosition);
int itemPosition = indexer.getPositionForSection(sectionPosition);
int typeView = adapter.getItemViewType(itemPosition);
if (isItemViewTypePinned(adapter, typeView)) {
return itemPosition;
} // else, no luck
}
// try slow way by looking through to the next section item above
for (int position=fromPosition; position>=0; position--) {
int viewType = adapter.getItemViewType(position);
if (isItemViewTypePinned(adapter, viewType)) return position;
}
return -1; // no candidate found
}
代码示例来源:origin: liaohuqiu/android-GridViewWithHeaderAndFooter
if (adjPosition >= 0 && adjPosition < adapterCount) {
if (adjPosition < mAdapter.getCount()) {
type = mAdapter.getItemViewType(adjPosition);
} else {
if (mCachePlaceHoldView) {
代码示例来源:origin: rey5137/material
int count = adapter.getCount();
for (int i = 0; i < count; i++) {
int newType = adapter.getItemViewType(i);
if (newType != viewType) {
child = null;
代码示例来源:origin: chentao0707/SimplifyReader
ViewGroup.LayoutParams.WRAP_CONTENT, 0);
p.viewType = mAdapter.getItemViewType(position);
p.scrappedFromPosition = position;
代码示例来源:origin: beworker/pinned-section-listview
@Override
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
if (mDelegateOnScrollListener != null) { // delegate
mDelegateOnScrollListener.onScroll(view, firstVisibleItem, visibleItemCount, totalItemCount);
}
// get expected adapter or fail fast
ListAdapter adapter = getAdapter();
if (adapter == null || visibleItemCount == 0) return; // nothing to do
final boolean isFirstVisibleItemSection =
isItemViewTypePinned(adapter, adapter.getItemViewType(firstVisibleItem));
if (isFirstVisibleItemSection) {
View sectionView = getChildAt(0);
if (sectionView.getTop() == getPaddingTop()) { // view sticks to the top, no need for pinned shadow
destroyPinnedShadow();
} else { // section doesn't stick to the top, make sure we have a pinned shadow
ensureShadowForPosition(firstVisibleItem, firstVisibleItem, visibleItemCount);
}
} else { // section is not at the first visible position
int sectionPosition = findCurrentSectionPosition(firstVisibleItem);
if (sectionPosition > -1) { // we have section position
ensureShadowForPosition(sectionPosition, firstVisibleItem, visibleItemCount);
} else { // there is no section for the first visible item, destroy shadow
destroyPinnedShadow();
}
}
};
代码示例来源:origin: UweTrottmann/SeriesGuide
@Override
public int getItemViewType(int position) {
return mAdapter.getItemViewType(position);
}
代码示例来源:origin: stackoverflow.com
return originalAdapter.getItemViewType(id);
代码示例来源:origin: UweTrottmann/SeriesGuide
int type = adapter.getItemViewType(position);
内容来源于网络,如有侵权,请联系作者删除!