2012-01-02 1 views
1

以下は、私のアダプタのコードで、私のlistviewの各項目の最初の文字をポップアップで作成し、連絡先アプリケーションに似たものを提供します。SectionIndexerでポップアップの色を変更するにはどうすればよいですか?

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

私はあなたがそれを行うことはできないと思っています。しかし、ここには[代替](http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/view/List9.html)があります。それに応じてウィンドウをカスタマイズすることもできますが、これは気にしないでくださいセクションに従ってスナップします。 – st0le

+0

これは答えです、あなたはそれを投稿して受け入れます;-) –

+0

完了! :)パディング – st0le

答えて

1

私はあなたがそれを行うことはできないと思っています。しかし、ここにはalternativeがあります。それに合わせてウィンドウをカスタマイズすることもできます。

関連する問題