2011-12-02 2 views
0

확장 가능 목록의 상위보기에 단추를 추가하려고합니다. 이것은 부모보기에 대한 내 레이아웃입니다.확장 가능 목록의 상위보기에 단추가 필요합니다

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:orientation="horizontal" > 

    <ImageView 
     android:id="@+id/explist_indicator" 
     android:layout_width="25dp" 
     android:layout_height="match_parent" 
     android:layout_weight=".25" 
     android:src="@drawable/expander_group" /> 

    <TextView 
     android:id="@+id/contacts" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_gravity="left" 
     android:layout_weight="1" 
     android:paddingLeft="20dp" 
     android:text="@string/contacts" 
     android:textSize="28dp" > 
    </TextView> 

    <Button 
     android:id="@+id/button1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_weight=".25" 
     android:background="@drawable/plus" 
     android:text="Button" /> 

</LinearLayout> 

정상적으로 자바 클래스에 버튼을 추가하지만 리스너를 추가하려고하면 null 포인터 예외가 발생합니다. 이 버튼을 추가하여 특정 부모의 모든 하위 항목을 선택/선택 취소합니다. 어떤 도움이라도 좋을 것입니다.

+0

일부 코드와 LogCat을 게시해야합니다. – kaspermoerch

답변

1

드롭 다운의 이미지를 만든 다음 그룹 표시기 속성을 통해 확장 가능한 목록보기에 연결하면 그룹 드롭 다운 표시기로 사용할 사용자 정의 이미지를 추가 할 수 있습니다. 그룹 표시기는 state_expanded 및 drawable 상태에서 사용할 이미지를 정의하는 drawable xml 파일입니다. 확장 가능한 목록보기의 경우 런타임에 그룹 표시기를 설정하는 코드가 필요합니다.