如何在SectionIndexer中更改弹出窗口的颜色?

时间:2012-01-02 09:52:22

标签: android colors android-widget

下面是我的适配器的代码,它允许使用listview的每个项目的第一个字母创建一个弹出窗口,并提供类似于联系人应用程序的内容。

enter image description here

不幸的是,颜色不正确,文字在灰色背景上是黑色的。

我的问题是:

我可以在哪里更改这些颜色?

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;
    }
}

1 个答案:

答案 0 :(得分:1)

从它的外观来看,我认为你无法做到。但是这里有一个alternative你可以相应地自定义窗口,但是请注意这不会按照部分进行捕捉。

相关问题