Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

Trying to create an ExpandableListView. The initial view with the groups shows up fine. However, when I click the list item, my arrow does not change. See the images below.

enter image description here

How can I change the arrow's direction?

The layout XML:

  <ExpandableListView
        android:id="@+id/expandable_list"
        android:layout_width="fill_parent"
        android:layout_height="match_parent"            
        android:divider="@null"
        android:background="#ffffff"
        android:groupIndicator="@drawable/settings_selector"
        android:transcriptMode="alwaysScroll" />

settings_selector.xml:

 <?xml version="1.0" encoding="utf-8"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android" >

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

</animation-list>
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
1.6k views
Welcome To Ask or Share your Answers For Others

1 Answer

expandable listview

 <ExpandableListView
    android:id="@+id/expandable_list"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:groupIndicator="@drawable/group_indicator"
    android:transcriptMode="alwaysScroll" />

setindicator here iam useing setindicator code like this this working nice

 DisplayMetrics metrics = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(metrics);
    int width = metrics.widthPixels; 

 mExpandableList = (ExpandableListView)findViewById(R.id.expandable_list);
 mExpandableList.setIndicatorBounds(width - GetPixelFromDips(50), width - GetPixelFromDips(10));  

   public int GetPixelFromDips(float pixels) {
    // Get the screen's density scale 
    final float scale = getResources().getDisplayMetrics().density;
    // Convert the dps to pixels, based on density scale
    return (int) (pixels * scale + 0.5f);
}

res/drawable/group_indicator

  <?xml version="1.0" encoding="utf-8"?>

     <selector xmlns:android="http://schemas.android.com/apk/res/android">????        
           <item android:drawable="@drawable/arrow_right" android:state_empty="true">  </item>????        
           <item android:drawable="@drawable/arrow_down" android:state_expanded="true"></item> ????           
           <item android:drawable="@drawable/arrow_right"></item>
     </selector>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share

548k questions

547k answers

4 comments

86.3k users

...