1

Below is the code of my adapter that allows to create a popup with the first letter of every item of my listview and provide something similar to the contact application.

enter image description here

Unfortunately, the colors are not correct and the text is black on a grey background.

My question is:

Where can I change these colors?

public class AlphabeticalAdapter extends ArrayAdapter<String> implements
        SectionIndexer {

    HashMap<String, Integer> alphaIndexer;
    String[] sections;

    public AlphabeticalAdapter(Context context, String[] items) {
        super(context, android.R.layout.simple_list_item_1, items);

        alphaIndexer = new HashMap<String, Integer>();
        int size = items.length;

        for (int x = 0; x < size; x++) {
            String s = items[x];

            // get the first letter of the store
            String ch = s.substring(0, 1);
            // convert to uppercase otherwise lowercase a -z will be sorted
            // after upper A-Z
            ch = ch.toUpperCase();

            // HashMap will prevent duplicates
            alphaIndexer.put(ch, x);
        }

        Set<String> sectionLetters = alphaIndexer.keySet();

        // create a list from the set to sort
        ArrayList<String> sectionList = new ArrayList<String>(sectionLetters);

        Collections.sort(sectionList);

        sections = new String[sectionList.size()];

        sectionList.toArray(sections);
    }

    public int getPositionForSection(int section) {
        return alphaIndexer.get(sections[section]);
    }

    public int getSectionForPosition(int position) {
        return 1;
    }

    public Object[] getSections() {
        return sections;
    }
}
bobbymcr
  • 23,769
  • 3
  • 56
  • 67
Waza_Be
  • 39,407
  • 49
  • 186
  • 260
  • 1
    From the looks of it I don't think you can do it. But here's an [alternative](http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/view/List9.html) you could customize the window accordingly but also note this wont snap according to sections. – st0le Jan 02 '12 at 10:05
  • This is the answer, you can post it and will accept ;-) – Waza_Be Jan 02 '12 at 10:42

1 Answers1

1

From the looks of it I don't think you can do it. But here's an alternative you could customize the window accordingly but also note this wont snap according to sections.

st0le
  • 33,375
  • 8
  • 89
  • 89