Extended List Change Icon

I would like to change the extended and standard icon of my Expandable List. I did some research on how to do this and found this question .

I think I did it as described there. I have 2 icons, the first is called defaulticon.png and the second is expandicon.png. Bothers are in a folder with the ability to move (not in drawable-hdpi). A list ad is as follows:

<ExpandableListView android:id="@+id/expandableListView" android:layout_width="match_parent" android:layout_height="wrap_content" android:groupIndicator="@drawable/groupindicator"> </ExpandableListView> 

The group identifier is an xml file, also located in a folder with the ability to transfer and looks like this:

 <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:drawable="@drawable/defaulticon" android:state_empty="true"/> <item android:drawable="@drawable/expandedicon" android:state_expanded="true"/> </selector> 

However, the icons do not change. The default icon disappears from the list view, and is missing instead. Are there any restrictions on resources (how much resources can be to me (both 160x160), where should they be located, ...). I am testing an application on my S3 running Android 4.1.2.

Greetings

+8
android android-listview expandablelistview
source share
2 answers

Change the icon size to 32 X 32, put the icon in drawable-mdpi , and then try this code

 <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:drawable="@drawable/expandedicon" android:state_expanded="true"/> <item android:drawable="@drawable/defaulticon"/> </selector> 
+5
source share

First of all, resize the image to 24 * 24, and then copy it to the drawable-mdpi on Android. After that, copy and paste this code:

 <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android" > <item android:drawable="@drawable/abc"android:state_empty="true"></item> <item android:drawable="@drawable/downarrow" ></item> </selector> 
-one
source share

All Articles