2013-07-14 58 views

回答

2

是的。假设ArrayAdapter,你将不得不做这样的事情:

public View getView(int position, View convertView, ViewGroup parent) { 

    ... 

    if (position % 2 == 0) { // Even numbered row 
     // set a color as background for view 
    } else { // Odd numbered row 
     // set another color as background for view 
    } 

    ... 

} 
0

是否有可能颜色的ListView用不同的颜色?

是的,它的可能性。您可以使用自定义适配器的列表视图。

关注这个tutorial ..

0

是的,它可能,用于该用途的getView()

public View getView(int position, View convertView, ViewGroup parent) { 

    ViewHolder holder = (ViewHolder) convertView.getTag(); 

    if (position == 0){ 
    holder.layout.setBackgroundColor(Color.RED); 
    } 
    if (position == 1){ 
    holder.layout.setBackgroundColor(Color.BLUE); 
    } 
} 

等等.....

+0

你能约持有人解释何为这 – user2515300

+0

@ user2515300看到我更新的答案! –