jhamm
jhamm

Reputation: 25032

I need a button in the parent view of an expandablelist

I am trying to add a button to the parentview of an expandablelist. This is my layout for the parentview.

<?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>

I add the button to the java class like normal, but get a null pointer exception when i try to add a listener. I am adding this button to select/deselect all the children of the particular parent. Any help would be great.

Upvotes: 0

Views: 165

Answers (1)

user1168952
user1168952

Reputation: 21

You can add a custom image to serve as the group drop down indicator by simply creating images of the drop down then hook it up to the expandable list view via it's group indicator property. The group indicator is a drawable xml file defining which image to use by state_expanded and drawable states. You will still need in code to set the group indicator at run time for the expandable list view.

Upvotes: 1

Related Questions