Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Image icon in expandable list view in android

Tags:

java

android

I want to add an image icon in expandable list view .I have seen the tutorial they have added only in child elements .Is there any other way to add image icon in parent Any help would be appreciated. Thanks in advance.

like image 754
Sam97305421562 Avatar asked Aug 31 '09 04:08

Sam97305421562


People also ask

What is Expandable list view in Android?

android.widget.ExpandableListView. A view that shows items in a vertically scrolling two-level list. This differs from the ListView by allowing two levels: groups which can individually be expanded to show its children. The items come from the ExpandableListAdapter associated with this view.

How do you use expandable list view?

Android ExpandableListView is a view that shows items in a vertically scrolling two-level list. It differs from a ListView by allowing two levels which are groups that can be easily expanded and collapsed by touching to view and their respective children items.


1 Answers

You can also define your own groupIndicator in XML:

First define your own drawable (I called it list_view_group_indicator.xml and placed it in the drawable directory)

<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item
        android:state_expanded="true"
        android:drawable="@drawable/packagexgeneric" />
    <item
        android:drawable="@drawable/packagexgenericclose" />
</selector>

Then use it as a drawable for your expandableListview

<ExpandableListView android:id="@+id/server_show_list"
    android:layout_width="fill_parent"android:layout_height="wrap_content"
    android:groupIndicator="@drawable/list_view_group_indicator" />
like image 128
Johnnycube Avatar answered Oct 25 '22 14:10

Johnnycube