在“扩展列表”中设置项目的颜色

时间:2010-11-15 09:14:37

标签: android

您好我在扩展列表视图中显示了一些项目。那些是项目及其类别。如果我们选择一个项目,那么当我们根据项目背景的状态设置打开该列表时,该项目状态将更新为db.next。如果状态为0,则为ex。该项目具有黑色背景。如果状态为1,则项目背景为白色。我正在将该项目状态更新为db并正确获取该值。但我不知道如何在显示时为扩展列表中的项目设置背景。请发布。给我一些建议。很紧急。谢谢你提前

2 个答案:

答案 0 :(得分:0)

public class MyExpandableListAdapter扩展了BaseExpandableListAdapter {

public View getChildView(int groupPosition,int childPosition,boolean isLastChild,             查看convertView,ViewGroup parent){

    TextViewtextView = getGenericView(false);

    textView.setText(getChild(groupPosition, childPosition).toString());

    convertView.setBackgroundColor(【there is color :-)】);
    return textView;
}

} ·········

你可以创建一个适配器: - )

并且在你的活动中:

MyExpandableListAdapter mAdapter = new MyExpandableListAdapter(this); 【your_ExpandableListViewName】.setAdapter(mAdapter);

答案 1 :(得分:0)

好 尝试更改代码---

getChildView()将更改Childview,抱歉,

您可以尝试更改:getGroupView()

好运的朋友