
请教各位高手如何实现?
ListView的内容在Adapter中配扰春辩置,你可以写一个BaseAdapter的子类,在getView方法中,利用position参数来获取当前Item的索引,判断索森首引的数值来决定这个Item的背景色或者其他的UI样式缓缺等
最佳答案并不是java语言锋颤,纳基桥Jquary完全不懂,但是基础语法都差不多,思路洞猛我也是看懂了,他的意思是取出每个item分别赋予颜色,有很多颜色需要分别赋予这么做也就算了,他还只付了两种……显然麻烦,而且万一有个百八十条不是累死了,我觉得楼主问的是如果是要一个黑一个白一个黑一个白那么排列的话………………实在懒,就不粘代码了,
这里给大家说说思路,如果你是真的做android的
其实就一句话
获取position,然后% 2 == 0的都设成黑色,else,全都设成白色就ok了,最佳答案下边也有写,只不过语法不同罢了
写一个adapter 根据里面的position里判颤逗断让洞脊是第几个然后setbackground就可坦渗以了啊
JQUERY,
方法一:$("Item").each(function(index,entity){
if(index==0)$(entity).css({backgroundColor:"White"});
if(index==1)$(entity).css({backgroundColor:"Gray"});
if(index==2)$(entity).css({backgroundColor:"White"汪携碰});
if(index==3)$(entity).css({backgroundColor:"Gray"});
});
方法二:
$("item:odd")..css({backgroundColor:"White"困谈});
$("item:even")..css({backgroundColor:"Gray"});
方法三:在后端:
if(item.index%2=0)
item.attributes.add("style","background-color:White;"隐桐);
else
item.attributes.add("style","background-color:Gray;");