SimpleExpandableListAdapter sections titles
I implemented my SimpleExpandableListAdapter
, and I'm trying to customize the section titles. To do this I pass to the constructor the id of a custom TextView
for the groupTo parameter:
setListAdapter( new SimpleExpandableListAdapter(this,
groupsData,
android.R.layout.simple_expandable_list_item_1,
new String[]{SECTION},
new int[]{R.id.list_group_title},
innerData,
0,
开发者_开发百科 null,
new int[]{}){ /*my code here*/ });
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/list_group_title"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="20dip" />
Problem is, nothing is showing up! The whole thing is blank, as if the view wasn't there. Any idea on why, or any link I could read up to solve this? Thanks!
MyAdapter ma = new MyAdapter(this,groupsData,android.R.layout.simple_expandable_list_item_1,new String[]{SECTION}, new int[]{R.layout.list_group_title},innerData,0,null,new int[]{});
setListAdapter(ma);
private static class MyAdapter extends SimpleExpandableListAdapter
{
LayoutInflater layoutInflater;
int title;
public MyAdapter(Context context,List<? extends Map<String, ?>> groupData,int groupLayout,String[ ] groupFrom,int[ ] groupTo,List<? extends List<? extends Map<String, ?>>> childData,int childLayout,String[ ] childFrom, int[ ] childTo)
{
super(context,groupData,groupLayout,groupFrom,groupTo,childData,childLayout,childFrom,childTo);
title = groupTo[0];
layoutInflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
@Override
public View getGroupView(int groupPosition,boolean isExpanded,View convertView,ViewGroup parent)
{
return (TextView)layoutInflater.inflate(title,null);
}
}
Inflating it in getGroupView
does the trick. Still, I don't understand why it is not passed automatically to the super
constructor.
精彩评论