Selector color not showing in custom ListView (pic)

1.5k views Asked by At

I've added a custom style to my ListView, but now a few odd things are happening.

1)When I click an item on the list, the selector(alt color) doesn't appear. Instead. The standard green selector comes up but it's BEHIND the rounded edges of each row in the list. It's as if the default ListView with standard black rows is bleeding out behind my styledenter code here one. Any ideas on how to fix this? Has anybody ever encountered similar issues while working with custom ListViews?

2)When I fling through the list, the background color changes back to standard Black, and is no longer blue as I designed.

So basically those two are the issues I'm facing right now, the selector not showing up and the black background "bleeding" out behind my grey row as I fling through the list. Any help/guidance on this issue would be great appreciated, thanks! I've attached a pic

Here is my listview_row.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/relativeLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="5dip" 
android:background="@drawable/listview_background"


>


<ImageView
    android:id="@+id/imgViewLogo"
    android:layout_width="50dip"
    android:layout_height="50dip"
    android:layout_alignParentLeft="true"
    android:scaleType="fitXY"
    android:src="@drawable/imgview_drawable" >

</ImageView>

<TextView
    android:id="@+id/txtViewTitle"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginLeft="2dip"
    android:layout_toRightOf="@+id/imgViewLogo"
    android:text="TextView"
    android:textAppearance="?android:attr/textAppearanceLarge"
    android:textColor="#43c6db"
    android:textStyle="bold" >
</TextView>

<TextView
    android:id="@+id/txtViewDescription"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/txtViewTitle"
    android:layout_marginLeft="2dip"
    android:layout_toRightOf="@+id/imgViewLogo"
    android:textStyle="bold"
    android:textColor="#000000"
    android:text="TextView" >
 </TextView>










</RelativeLayout>

This is my main ListView layout

 <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" 
android:background="#708090"
>



<ListView
    android:id="@+id/lvAlbumList"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:choiceMode="multipleChoice"
    android:clickable="false"
    android:divider="@drawable/list_divider"
    android:dividerHeight="2dp"
    android:padding="2dp"
    android:listSelector="@drawable/selector"

    android:cacheColorHint="#00000000"

     >




</ListView>

</LinearLayout>

And finally here is my selector.xml, which is a State list drawable

 <?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">

<item android:state_pressed="true"
      android:drawable="@drawable/list_item_pressed"/>

<item android:state_focused="true"
      android:drawable="@drawable/list_item_selected" />

<item android:drawable="@drawable/list_item_normal" />

</selector>

[1]: https://p.twimg.com/AiLoEMVCAAIz_6E.png ""

1

There are 1 answers

0
loks On

just try to set list selector "null" or remove list selector.

And instead of setting list selector set selector on your custom list row view in adapter.