解决方案 »

  1.   

    在adapter中的getview里面
    if (position % 2 == 0) {//奇偶行背景色
       contentView.setBackgroundColor(contentView.getResources().getColor(R.color.palegreen));
      }else {
       contentView.setBackgroundColor(contentView.getResources().getColor(R.color.lightgreen));
      }
      

  2.   

    你首先得为你的contentView设置Background,然后设置BackgroundColor才能看到效果
      

  3.   

    我是直接设置<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" 
        android:minHeight="80dp"
        android:paddingBottom="5dp"
        android:paddingLeft="5dp"
        android:paddingTop="5dp"
        android:id="@+id/rl_main"
        >

    if (arg0 % 2 == 0) {
    viewholder.rl_main.setBackgroundColor(R.color.Black);
    }else
    {
    viewholder.rl_main.setBackgroundColor(R.color.White);
    }
      

  4.   

    可以在adapter的的view中代码设置背景色通过position来区别奇偶~
      

  5.   

         这个之前遇到过,你直接在contentView里面设置是不行的。
         是需要把焦点获取到item上面。然后再给contentView设置背景。通过position操作contentView就可以了。可以试试,不一定好使。