빠른 스크롤을 지원하는 레이아웃에 ListView가 포함 된 앱을 작성했습니다. 즉, 스크롤 막대 슬라이더를 드래그하면 목록을 빠르게 위 또는 아래로 스크롤 할 수 있습니다. 이것은 Jelly Bean (4.1-4.3)의 모든 버전에서 완벽하게 작동했습니다. 그러나 Kit Kat으로 업데이트 한 후에는 빠른 스크롤이 더 이상 작동하지 않으며 내 스크롤 막대는 일반 스크롤 막대에 불과합니다. 그러나 내 앱에서 빠져 나와 다시 들어가면 빠른 스크롤이 표시됩니다. Kit Kat에서 꾸준한 작업을 위해 빠른 스크롤을 얻으려면 어떻게해야합니까? 나는, 복사 아래에있는 내 목록보기 어댑터 코드를 붙여했습니다 :Android에서 빠른 스크롤 관련 문제 4.4
// Adds section popup for fast scroll
class NameListAdapter extends SimpleAdapter implements SectionIndexer {
HashMap<String, Integer> alphaIndexer;
private String[] sections;
private ArrayList<String> sectionList;
private List<HashMap<String, String>> data = null;
public NameListAdapter (Context context, List<HashMap<String, String>> data,
int resource, String[] from, int[] to) {
super(context, data, resource, from, to);
alphaIndexer = new HashMap<String, Integer>();
sectionList = new ArrayList<String>();
this.data = data;
int size = data.size();
for (int i = 0; i < size; i++) {
HashMap<String, String> myData = (HashMap <String, String>) data.get(i);
// Get first character
String ch = myData.get("name").substring(0, 1);
// Convert character to upper case
ch = ch.toUpperCase();
// Put first char/index into our HashMap
if (!alphaIndexer.containsKey(ch)) {
alphaIndexer.put(ch, i);
sectionList.add(ch);
}
}
sections = new String[sectionList.size()];
sectionList.toArray(sections);
}
@Override
public int getPositionForSection(int section) {
if (section >= sections.length) {
return getCount() - 1;
}
return alphaIndexer.get(sections[section]);
}
@Override
public int getSectionForPosition(int pos) {
if (pos > data.size()) {
return 0;
}
HashMap<String, String> myData = (HashMap <String, String>) data.get(pos);
String ch = myData.get("name").substring(0, 1);
// Convert character to upper case
ch = ch.toUpperCase();
for (int i = 0; i < sectionList.size(); i++) {
if (sectionList.get(i).equals(ch)) {
return i;
}
}
return 0;
}
@Override
public Object[] getSections() {
return sections;
}
}
내가이 때문에 스타 주시기에 대한 버그를 열었습니다. https://code.google.com/p/android/issues/detail?id=63545&colspec=ID%20Type%20Status%20Owner%20Summary%20Stars –
나를위한 동일한 문제 – JeffG
이것은 Android v4에서 해결 된 것으로 보입니다. 4.3. – mikejonesguy