Android Gridview selector

1.1k views Asked by At

I have a gridview with transparent rows. On selecting a row the row get highlighted to a light blue color. this all works fine.

Now I want to add different colors to the gridview ie. green and red. this indicates different categories. I have managed to set the background of the rows. but now when clicking on a red or green row the gridview list selector is not working.

My GridView:

<GridView>
    android:id="@+id/gridView1"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:listSelector="#23fdfa"
    android:scrollbars="vertical|horizontal"
    android:stretchMode="columnWidth" >              
</GridView>

Green Rows:

<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" >   
   <stroke android:width="1dip" android:color="#4fa5d5"/>   
   <gradient android:startColor="#00FD0D" android:endColor="#00FD0D"/>  
</shape>

Red Rows:

<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" >

   <stroke android:width="1dip" android:color="#4fa5d5"/>
   <gradient android:startColor="#FF4A59" android:endColor="#FF4A59"/>

</shape>

Red and Green rows get populated fine when adding items to the gridview.

1

There are 1 answers

0
user3074196 On BEST ANSWER

I have added this line to my GridView : android:drawSelectorOnTop="true"