2012-01-02 4 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이 있습니다. 그에 따라 창을 사용자 정의 할 수도 있지만 섹션에 따라 스냅하지 마십시오.

관련 문제