1. Set expandablelistview to expand by default.:
Instantiate exlistview first
Then
Exlistview. setadapter (exlvadapter );
// Traverse all groups and set all items to expand by default
Int groupcount = exlistview. getcount ();
For (INT I = 0; I <groupcount; I ++ ){
Exlistview. expandgroup (I );
};
2. Remove the default arrow of expandablelistview.
When using expandablelistview, there is an arrow icon that comes with the system. In your custom layout, you cannot just set an attribute, as shown below:
Settinglists. setgroupindicator (null );~~~~~~~~~~~~~~~~~ This is to set a custom Sequence Graph. If this parameter is set to null, no more.
It can also be customized (but the location is not recommended in that place) as follows:
First, customize an expandablelistviewselector. xml file. The specific content is as follows:
Java code
<? XML version = "1.0" encoding = "UTF-8"?>
<Selector xmlns: Android = "http://schemas.android.com/apk/res/android">
<Item Android: state_expanded = "true" Android: drawable = "@ drawable/expandablelistviewindicatordown"/>
<Item Android: drawable = "@ drawable/expandablelistviewindicator"/>
</Selector>
Add the following code:
Settinglists. setgroupindicator (this. getresources (). getdrawable (R. layout. expandablelistviewselector ));
Success
3. Change the default arrow to display on the right:
1 first, expandablelistview elistview;
Elistview. setgroupindicator (null); // remove the default left arrow of the control,
2. There is a method in the Custom adapter that inherits from baseexpandablelistadapter.
/**
* Parent Class View
*/
@ Override
Public View getgroupview (INT groupposition, Boolean isexpanded,
View convertview, viewgroup parent ){
Log. I ("zhaoxiong", "parent View ");
Linearlayout parentlayout = (linearlayout) view. Inflate (context, R. layout. wowocoupons_parent_item, null );
Textview parenttextview = (textview) parentlayout. findviewbyid (R. Id. parentitem );
Parenttextview. settext (parentlist. Get (groupposition ));
Imageview parentimageviw = (imageview) parentlayout. findviewbyid (R. Id. Arrow );
// Determine whether isexpanded can be used to control whether to press or close, and change the image at the same time
If (isexpanded ){
Parentimageviw. setbackgroundresource (R. drawable. arrow_down );
} Else {
Parentimageviw. setbackgroundresource (R. drawable. arrow_up );
}
Return parentlayout;
}