एक बार FastScroller
(अपने AbsListView
वर्ग कि ListView
तक फैली हुई है में) SectionIndexer#getSections()
फोन करके अपने वर्गों प्राप्त करता है, यह कभी नहीं उन्हें फिर से प्राप्त जब तक आप को सक्षम/अक्षम लिंक आप का उल्लेख में उल्लेख की तरह तेजी से स्क्रॉल। स्क्रीन पर मूल्य प्रदर्शित करने के लिए, फास्टस्क्रॉलर अनुभाग की टूस्ट्रिंग विधि को कॉल करता है। यदि वर्गों अंग्रेजी का प्रतिनिधित्व करते हैं,
उदा। अपने कस्टम SectionIndexer
private int mLastPosition;
public int getPositionForSection(int sectionIndex) {
if (sectionIndex < 0) sectionIndex = 0;
// myCurrentSectionLength is the number of sections you want to have after
// re-indexing the items in your ListView
// NOTE: myCurrentSectionLength must be less than getSections().length
if (sectionIndex >= myCurrentSectionLength) sectionIndex = myCurrentSectionLength - 1;
int position = 0;
// --- your logic to find the position goes in here
// --- e.g. see the AlphabeticIndexer source in Android repo for an example
mLastPosition = position;
return mLastPosition;
}
public Object[] getSections() {
// Assume you only have at most 3 section for this example
return new MySection[]{new MySection(), new MySection(), new MySection()};
}
// inner class within your CustomSectionIndexer
public class MySection {
MySection() {}
public String toString() {
// Get the value to displayed based on mLastPosition and the list item within that position
return "some value";
}
}
द्वारा ListView के लिए वर्गों सूची पुन: लोड मैं कुछ कर रहा हूँ मजबूर कर सकते हैं समान यहाँ http://stackoverflow.com/questions/10224233/alphabetindexer-with-custom-adapter-managed-by-loadermanager – toobsco42