當前位置: 首頁>>代碼示例>>Java>>正文


Java SectionIndexer.getSectionForPosition方法代碼示例

本文整理匯總了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
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:24,代碼來源:PinnedSectionListView.java

示例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
}
 
開發者ID:lanyan520,項目名稱:Idea-ChainSelector,代碼行數:24,代碼來源:PinnedSectionListView.java

示例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
}
 
開發者ID:nordfalk,項目名稱:EsperantoRadio,代碼行數:22,代碼來源:PinnedSectionListView.java

示例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
}
 
開發者ID:mrprona92,項目名稱:SecretBrand,代碼行數:22,代碼來源:PinnedSectionListView.java

示例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
}
 
開發者ID:mzule,項目名稱:AndroidWeekly,代碼行數:24,代碼來源:PinnedSectionListView.java

示例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
}
 
開發者ID:BigAppOS,項目名稱:BigApp_Discuz_Android,代碼行數:22,代碼來源:PinnedSectionListView.java

示例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
}
 
開發者ID:xulailing,項目名稱:android-open-project-demo-master,代碼行數:22,代碼來源:PinnedSectionListView.java

示例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
}
 
開發者ID:LeshiyGS,項目名稱:shikimori,代碼行數:23,代碼來源:PinnedSectionGridView.java

示例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
}
 
開發者ID:LeshiyGS,項目名稱:shikimori,代碼行數:23,代碼來源:PinnedSectionListView.java

示例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
}
 
開發者ID:bitjjj,項目名稱:GameRecorder,代碼行數:23,代碼來源:PinnedSectionListView.java

示例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
}
 
開發者ID:wefika,項目名稱:pinned-section-listview,代碼行數:22,代碼來源:PinnedSectionListView.java

示例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;
}
 
開發者ID:kuastw,項目名稱:KUAS-AP-Material,代碼行數:30,代碼來源:PinnedSectionListView.java


注:本文中的android.widget.SectionIndexer.getSectionForPosition方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。