我想为每个组显示不同的子布局,例如:
@Override
public View getChildView(int groupPosition, int childPosition,
boolean isLastChild, View convertView, ViewGroup parent) {
if (convertView == null) {
switch (groupPosition){
case 0:
LayoutInflater inflater = (LayoutInflater) myContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = inflater.inflate(R.layout.child_row, null);
TextView tvPlayerName = (TextView) convertView.findViewById(R.id.tvPlayerName);
tvPlayerName.setText(arrChildelements[groupPosition][childPosition]);
break;
case 1:
LayoutInflater inflater1 = (LayoutInflater) myContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = inflater1.inflate(R.layout.child_row1, null);
TextView tvPlayerName1 = (TextView) convertView.findViewById(R.id.tvPlayerName);
tvPlayerName1.setText(arrChildelements[groupPosition][childPosition]);
break;
case 2:
LayoutInflater inflater2 = (LayoutInflater) myContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = inflater2.inflate(R.layout.child_row2, null);
TextView tvPlayerName2 = (TextView) convertView.findViewById(R.id.tvPlayerName);
tvPlayerName2.setText(arrChildelements[groupPosition][childPosition]);
break;
case 3:
LayoutInflater inflater3 = (LayoutInflater) myContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = inflater3.inflate(R.layout.child_row3, null);
TextView tvPlayerName3 = (TextView) convertView.findViewById(R.id.tvPlayerName);
tvPlayerName3.setText(arrChildelements[groupPosition][childPosition]);
break;
}
} return convertView;
}
我的问题是在单击组时,子列表在组之间相互转换。
谁能告诉我我做错了什么?