效果图:
核心代码:
public View getGroupView(int groupPosition, boolean isExpanded,
View convertView, ViewGroup parent) {
View view = convertView;
if (view == null) {
LayoutInflater inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
view = inflater.inflate(R.layout.member_listview, null);
}
//一级列表中显示的标题
TextView txtFather = (TextView) view.findViewById(R.id.txtFather);
txtFather.setText(getGroup(groupPosition).toString());
return view;
}
public View getChildView(int groupPosition, int childPosition,
boolean isLastChild, View convertView, ViewGroup parent) {
View view = convertView;
if (view == null) {
LayoutInflater inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
view = inflater.inflate(R.layout.member_childitem, null);
}
//类别
final TextView txtAccountType = (TextView) view
.findViewById(R.id.txtAccountType);
txtAccountType.setText(accountChild.get(groupPosition).get(childPosition)
.get(ExListView.FATHERACCOUNT).toString());
//子类别
final TextView txtChildType = (TextView) view.findViewById(R.id.txtChildType);
txtChildType.setText(accountChild.get(groupPosition).get(childPosition)
.get(ExListView.CHILDACCOUNT).toString());
//余额
TextView txtBalance = (TextView) view.findViewById(R.id.txtBalance);
txtBalance.setText(accountChild.get(groupPosition).get(childPosition)
.get(ExListView.BALANCEACCOUNT).toString());
ImageView imgDraw = (ImageView) view.findViewById(R.id.imgDraw);
imgDraw.setBackgroundResource(R.drawable.icon_drag);
return view;
}
源代码为:
转载:http://www.adobex.com/android/source/details/00000388.htm