2010-11-15 78 views
1

嗨我显示扩大列表视图中的一些项目。那些是项目及其类别。如果我们选择一个项目,那么当我们根据设置该项目背景的状态打开该列表时,该项目状态将更新为db.next。如果状态为0,则为ex例如,具有黑色背景的项目如果状态是1,那么项目背景是白色的。我正在将该项目状态更新为db,并准确获取该值。但是我不知道如何在展开列表中设置项目的背景。请给我一些suggestions.it是提前urgent.Thanks在扩展列表中设置项目的颜色

回答

0

公共类MyExpandableListAdapter扩展BaseExpandableListAdapter {

公众查看getChildView(INT groupPosition,INT childPosition,布尔isLastChild, 查看convertView,ViewGroup以及母公司){

TextViewtextView = getGenericView(false); 

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

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

} ·········

u能创建一个适配器:-)

,并在您acticity:

MyExpandableListAdapter mAdapter =新MyExpandableListAdapter(本); 【your_ExpandableListViewName】.setAdapter(mAdapter);

+0

我想只为扩展列表中的特定项目设置背景 – Pinki 2010-11-15 12:08:14

+0

我正在使用SimpleExpandableListAdapter将元素设置为适配器。请给我一些建议。 – Pinki 2010-11-15 12:26:38

+0

使用SimpleExpandableListAdapter或使用BaseExpandableListAdapter,是既有getChildView()和getGroupView(),尝试它 – Ellison 2010-11-16 01:12:53

0

以及 尝试更改代码---

getChildView()将改变Childview,对不起,

你可以尝试改变:getGroupView()

好运朋友