Una volta che il FastScroller
(la sua in AbsListView
classe che si estende da ListView
) ottiene le sezioni chiamando SectionIndexer#getSections()
, non è mai ri-ottiene a meno che non si abilita/disabilita veloce scorrimento come indicato nel link che hai citato. Per ottenere il valore da visualizzare sullo schermo, FastScroller chiama il metodo toString della sezione.
Una possibile soluzione è quella di avere un costume SectionIndexer
che hanno le seguenti caratteristiche:.
- La matrice sezioni è di lunghezza fissa (lunghezza massima del numero atteso di sezioni Ad esempio, se le sezioni rappresentano inglese alfabeto sarà 26)
- avere un oggetto personalizzato per rappresentare sezioni, invece di usare le stringhe
- sovrascrivere il metodo
toString
del vostro oggetto sezione personalizzata per visualizzare ciò che si desidera in base ai 'valori sezione' correnti. -
ad es. Nella vostra abitudine 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";
}
}
sto facendo qualcosa di simile QUI http://stackoverflow.com/questions/10224233/alphabetindexer-with-custom-adapter-managed-by-loadermanager – toobsco42