我可以在子组中显示文本,但我无法在特定的子组中显示图像。
plz help
提前致谢
答案 0 :(得分:0)
我认为这对你有用......
public View getChildView(int groupPosition, int childPosition,
boolean isLastChild, View convertView, ViewGroup parent) {
View view= getGenericGroupView(groupPosition ,convertView);
return view;
}
public View getGenericGroupView(int groupPosition, View convertView) {
// Layout parameters for the ExpandableListView
View view=null;
try{
AbsListView.LayoutParams lp = new AbsListView.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT, 90);
view=convertView;
Holder holder=new Holder();
if(convertView==null)
{
LayoutInflater inflator=(LayoutInflater) ExpandableList1.this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
view=inflator.inflate(R.layout.inflate, null);
view.setLayoutParams(lp);
view.setPadding(80, 5, 5, 5);
holder.image=(ImageView)view.findViewById(R.id.image);
view.setTag(holder);
}
else
{
holder=(Holder) view.getTag();
}
holder.image.setImageResource(R.drawable.image);
}catch (Exception e) {
e.printStackTrace();
// TODO: handle exception
}
return view;
}
private class Holder
{
private ImageView image;
}