嘿,是否有可能更改ExpandableListView中指定行的背景?我想要的是:第一排藍色,第二條紅色,第三條藍色,第四條紅色......謝謝更改ExpandableListView中每一行的背景顏色?
1
A
回答
0
您可能想查看this thread: Android ExpandableListView。
有一個working sample具有您想要的功能(根據所保存的數據對行進行着色)。
0
當然。您只需在創建或重新創建視圖時手動設置視圖的背景。在基於組和兒童地位
1
是的,這是可能的,你必須使用自定義適配器爲您的擴展列表視圖的方法
getChildView(int groupPosition, int childPosition, boolean isLastChild, View convertView, ViewGroup parent)
做到這一點的適配器。
@Override
public View getChildView(int groupPosition, int childPosition, boolean isLastChild,
View convertView, ViewGroup parent) {
//......
//...... Your code for row view
//.....
//Now write here code for set colors for rows
if(childPosition % 2 == 0) {
convertView.setBackgroundColor("#0000FF"); // use this when you want to use hexa value of colors
} else {
convertView.setBackgroundColor("#FF0000"); // use this when you want to use hexa value of colors
}
//setBackgroundResource(android.R.color.transparent); // use this for predefined colors at place of setBackground
return convertView;
}
閱讀this文章,這裏例如和源代碼也可以。
相關問題
- 1. 更改行的背景顏色extjs4
- 2. 更改背景顏色
- 3. 更改背景顏色
- 4. 更改背景顏色
- 5. jqueryMobile更改背景顏色
- 6. 更改DIV背景顏色
- 7. 更改背景顏色
- 8. Gnuplot - 更改背景顏色
- 9. 更改背景顏色
- 10. 更改TToolBar背景顏色
- 11. model.addrow()更改背景顏色
- 12. QMenu更改背景顏色
- 13. WPF雙擊更改行背景顏色
- 14. 更改enhancedGrid行顏色背景
- 15. C#更改背景顏色特定行
- 16. 更改UITabBar的色調/背景顏色
- 17. 更改背景顏色更改邊框
- 18. 更改活動中的背景顏色。
- 19. 更改ListBoxItem ItemTemplate中的背景顏色?
- 20. 更改Swift中UITabBarItem的背景顏色
- 21. 更改VB6中ListView的背景顏色
- 22. 更改行上的背景顏色,但不更改行標題
- 23. 更改一行中豐富的背景顏色:dataTable
- 24. JTable中如何更改背景顏色
- 25. 在kivy中更改背景顏色
- 26. 在CSS中更改背景顏色
- 27. 更改按鈕顏色作爲背景顏色更改?
- 28. 使用AJAX更改表格中每個var的背景顏色
- 29. 在運行時更改Datagrid wpf中的行的背景顏色
- 30. 更改iframe問題的背景顏色
我得到這個錯誤:「Main2類型的方法getChildView(int,int,boolean,View,ViewGroup)必須覆蓋或實現一個超類型方法」..這可能是因爲我將我的類擴展到Activity而不是BaseExpandableListAdapter? – Omar 2011-04-15 17:41:50