本文整理匯總了Java中android.widget.SectionIndexer.getSectionForPosition方法的典型用法代碼示例。如果您正苦於以下問題:Java SectionIndexer.getSectionForPosition方法的具體用法?Java SectionIndexer.getSectionForPosition怎麽用?Java SectionIndexer.getSectionForPosition使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.widget.SectionIndexer
的用法示例。
在下文中一共展示了SectionIndexer.getSectionForPosition方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: findCurrentSectionPosition
import android.widget.SectionIndexer; //導入方法依賴的package包/類
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
}
示例2: findCurrentSectionPosition
import android.widget.SectionIndexer; //導入方法依賴的package包/類
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
}
示例3: findCurrentSectionPosition
import android.widget.SectionIndexer; //導入方法依賴的package包/類
int findCurrentSectionPosition(int fromPosition) {
ListAdapter adapter = getAdapter();
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
}
示例4: findCurrentSectionPosition
import android.widget.SectionIndexer; //導入方法依賴的package包/類
int findCurrentSectionPosition(int fromPosition) {
ListAdapter adapter = getAdapter();
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=Math.min(fromPosition,adapter.getCount()-1); position>=0; position--) {
int viewType = adapter.getItemViewType(position);
if (isItemViewTypePinned(adapter, viewType)) return position;
}
return -1; // no candidate found
}
示例5: findCurrentSectionPosition
import android.widget.SectionIndexer; //導入方法依賴的package包/類
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
}
示例6: findCurrentSectionPosition
import android.widget.SectionIndexer; //導入方法依賴的package包/類
int findCurrentSectionPosition(int fromPosition) {
ListAdapter adapter = getAdapter();
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
}
示例7: findCurrentSectionPosition
import android.widget.SectionIndexer; //導入方法依賴的package包/類
int findCurrentSectionPosition(int fromPosition) {
ListAdapter adapter = getAdapter();
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
}
示例8: findCurrentSectionPosition
import android.widget.SectionIndexer; //導入方法依賴的package包/類
int findCurrentSectionPosition(int fromPosition) {
PinnedSectionGridAdapter adapter = getPinnedAdapter();
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, itemPosition)) {
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, position))
return position;
}
return -1; // no candidate found
}
示例9: findCurrentSectionPosition
import android.widget.SectionIndexer; //導入方法依賴的package包/類
int findCurrentSectionPosition(int fromPosition) {
PinnedSectionListAdapter adapter = getPinnedAdapter();
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, itemPosition)) {
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, position))
return position;
}
return -1; // no candidate found
}
示例10: findCurrentSectionPosition
import android.widget.SectionIndexer; //導入方法依賴的package包/類
int findCurrentSectionPosition(int fromPosition) {
ListAdapter adapter = getAdapter();
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--) {
if(position >= adapter.getCount())break;//fix by bitjjj
int viewType = adapter.getItemViewType(position);
if (isItemViewTypePinned(adapter, viewType)) return position;
}
return -1; // no candidate found
}
示例11: findCurrentSectionPosition
import android.widget.SectionIndexer; //導入方法依賴的package包/類
private int findCurrentSectionPosition(int fromPosition) {
PinnedSectionListAdapter adapter = (PinnedSectionListAdapter) getAdapter();
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 (adapter.isItemViewTypePinned(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 (adapter.isItemViewTypePinned(viewType)) return position;
}
return -1; // no candidate found
}
示例12: findCurrentSectionPosition
import android.widget.SectionIndexer; //導入方法依賴的package包/類
int findCurrentSectionPosition(int fromPosition) {
ListAdapter adapter = getAdapter();
// dataset has changed, no candidate
if (fromPosition >= adapter.getCount()) {
return -1;
}
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;
}
}
// no candidate found
return -1;
}