Q:

How to add border to listview and different row colors at the same time

I'm trying to have a border on the outside of my listview and a different color for every other row at the same time 

here's the getView method from my adapter
        viewHolder.dateView.setText(entry.getDateString("yyyy-MM-dd HH:mm"));
        if(position % 2 == 0){
            viewHolder.linearLayout.setBackgroundResource(R.color.grey);

        }
        else{
            //viewHolder.linearLayout.setBackgroundResource(R.color.white);
        }

here's the xml file which I use to make the border on the listview not the cell
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" >
   <!-- use this for transparent -->
   <!-- <solid android:color="#00000000" /> -->
   <!-- use this for a background colour -->
   <solid android:color="@color/white" />
   <stroke android:width="2dip" android:color="@color/black"/>
</shape>

if I set the backround to the cell it I can no longer see the border

A:

Rewrite
You have obviously read: How do you put a border around a ListView? since you are using the code from the better / more popular answer. But read the bottom answer as well, I had success by adding 2dp padding (the same width as the border.)
  <LinearLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@drawable/border_listview"
    android:gravity="center_horizontal"
    android:orientation="vertical"
    android:padding="2dp" >

    <ListView
        android:id="@+id/listView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:divider="@null"
        android:dividerHeight="0dp" />
</LinearLayout>

