2011-05-13 2 views
1

헤더를 추가하는 데 Jeff Sharkey's SeparatedListAdapter을 사용하고있었습니다.
처음에는 모든 것이 괜찮 았습니다.
그러나 헤더의 정확히 동일한 String을 추가하면 문제가 나타납니다.
헤더가 올바르게 표시되지 않았지만 일부 헤더가 부족합니다.
이 문제는 헤더의 동일한 문자열을 변경했을 때 해결되었습니다.
그러나 동일한 String 헤더를 사용해야하는 경우에는 어떻게해야합니까?
나는 문제가 있기 때문에 ...Jeff Sharkey의 SeparatedListAdapter 버그

public final ArrayAdapter<String> headers; 

감사의 일이 같아요. 나는 그것 때문에 일어난 것을 발견


... 때문에지도의

public final Map<String, Adapter> sections = new LinkedHashMap<String, Adapter>(); 

때문에 중복 된 문자열 키가 문제의 원인이됩니다.
지도는 내게 필요한지도가 무엇인지 알지 못합니다.

그래서, 누가 다른 SeparatedListAdapter를 사용하여 중복 String 키를 사용할 수 있는지 알고 있습니까? 또는 어떻게 해결할 수 있습니까?

감사합니다.

답변

2

나는 아래의 방법을 SeparatedListAdapter 클래스에 추가하여 사용했습니다.

/** 
* If you need to show the duplicate header name, use this method to add 
* section, be sure that the id must be different. 
* CHT 2011/05/14 
* @param id 
*   must differ from each other or problems will happen 
* @param section 
*   header name 
* @param adapter 
*/ 
public void addSection(String id, String section, Adapter adapter) { 
    this.headers.add(section); 
    this.sections.put(id, adapter); 

    // Register an observer so we can call notifyDataSetChanged() when our 
    // children adapters are modified, otherwise no change will be visible. 
    adapter.registerDataSetObserver(mDataSetObserver); 
}