嘿,是否有可能更改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. 如何更改Android中ExpandableListView的背景顏色?
- 2. 更改行背景SlickGrid表的顏色。
- 3. 更改行的背景顏色extjs4
- 4. 更改背景顏色3
- 5. jqueryMobile更改背景顏色
- 6. 更改背景顏色tabhost
- 7. 更改UIButton背景顏色
- 8. 更改背景顏色8
- 9. WL.SimpleDialog更改背景顏色
- 10. 更改背景顏色
- 11. UICollectionViewCell更改背景顏色
- 12. 更改QLPreviewController背景顏色
- 13. 更改背景顏色
- 14. 更改UIAlertcontroller背景顏色
- 15. 更改TToolBar背景顏色
- 16. Gnuplot - 更改背景顏色
- 17. select2更改背景顏色
- 18. 更改fancybox2背景顏色
- 19. 更改背景顏色
- 20. 更改DIV背景顏色
- 21. 更改背景顏色
- 22. 更改Listitem背景顏色
- 23. QMenu更改背景顏色
- 24. 更改背景顏色
- 25. 更改HighCharts背景顏色?
- 26. 更改背景顏色
- 27. model.addrow()更改背景顏色
- 28. 更改背景顏色
- 29. 更改UITableViewController背景顏色
- 30. 更改背景顏色
我得到這個錯誤:「Main2類型的方法getChildView(int,int,boolean,View,ViewGroup)必須覆蓋或實現一個超類型方法」..這可能是因爲我將我的類擴展到Activity而不是BaseExpandableListAdapter? – Omar 2011-04-15 17:41:50