Note that there are some explanatory texts on larger screens.

plurals
  1. POScrollbar disappears when using SectionIndexer at specific sections on HoneyComb
    primarykey
    data
    text
    <p>I'm using adapter for <code>ListView</code> that implements <code>SectionIndexer</code>. <code>ListView</code> has <code>fastScrollEnabled</code> set to true in xml file. Everything works great on Android 2.2 and 2.3, but when I test my application on a tablet with Android 3.0, at some sections scrollbar disappears. For example when I scroll down the list, at elements beginning with letters A-B scrollbar is visible, but for letters C-H it's not, and then after H again visible. </p> <p>This adapter is made for sorting content alphabetically in ListView so that fastscroll can be used. </p> <p>Application is designed for API Level 8, so I couldn't use fastScrollAlwaysVisible.</p> <p>Here is a code of my adapter:</p> <pre><code>public class AlphabetSimpleAdapter extends SimpleAdapter implements SectionIndexer { private HashMap&lt;String, Integer&gt; charList; private String[] alphabet; public Typeface tfSansMedium; public Context mContext; public int mResource; public int[] mTo; public List&lt;? extends Map&lt;String, ?&gt;&gt; mData; public String mTitleKey; public AlphabetSimpleAdapter(Context context, List&lt;? extends Map&lt;String, ?&gt;&gt; data, int resource, String[] from, int[] to, String titleKey /* key sent in hashmap */) { super(context, data, resource, from, to); mData = data; mTitleKey = titleKey; mContext = context; mResource = resource; mTo = new int[to.length]; for ( int i = 0; i &lt; to.length; i ++) { mTo[i] = to[i]; } charList = new HashMap&lt;String, Integer&gt;(); int size = data.size(); tfSansMedium = Typeface.createFromAsset(context.getAssets(), "fonts/VitesseSans-Medium.otf"); for(int i = 0; i &lt; size; i++) { // Parsing first letter of hashmap element String ch = data.get(i).get(titleKey).toString().substring(0, 1); ch = ch.toUpperCase(); if(!charList.containsKey(ch)) { charList.put(ch, i); // Using hashmap to avoid duplicates } } Set&lt;String&gt; sectionLetters = charList.keySet(); // A set of all first letters ArrayList&lt;String&gt; sectionList = new ArrayList&lt;String&gt;(sectionLetters); // Creating arraylist to be able to sort elements Collections.sort(sectionList, Collator.getInstance(new Locale("pl", "PL"))); // Sorting elements alphabet = new String[sectionList.size()]; sectionList.toArray(alphabet); } // Methods required by SectionIndexer @Override public View getView(int position, View convertView, ViewGroup parent) { View v = convertView; if (v == null) { LayoutInflater li = (LayoutInflater)mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE); v = li.inflate(mResource, null); } for (int i = 0; i &lt; mTo.length; i ++) { TextView tv = (TextView)v.findViewById(mTo[i]); if (tv != null) tv.setTypeface(tfSansMedium); } return super.getView(position, v, parent); } @Override public int getPositionForSection(int section) { if(!(section &gt; alphabet.length-1)) { return charList.get(alphabet[section]); } else { return charList.get(alphabet[alphabet.length-1]); } } @Override public int getSectionForPosition(int position) { return charList.get(mData.get(position).get(mTitleKey).toString().substring(0, 1)); } @Override public Object[] getSections() { return alphabet; } } </code></pre> <p><code>charList</code> is a HashMap where I store letters with their last appearing index so when I have 6 elements starting with letter "A", the value for key "A" is 5 and so on. </p> <p><code>alphabet</code> is a String array with all existing first letters.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload