abhishek kumar
abhishek kumar

Reputation: 7

Android : selectors for custom listviews

<?xml version="1.0" encoding="utf-8"?>
 <selector xmlns:android="http://schemas.android.com/apk/res/android">
  <item android:state_focused="true" android:drawable="@drawable/layout_bg1" /> <!-- focused -->
  <item android:state_pressed="true" android:drawable="@drawable/layout_bg1" /> <!-- pressed -->
  <item android:drawable="@drawable/layout_bg" /> <!-- default -->
</selector> 

I am trying to use custom drawables in my list selector.Here is the error message I am getting in the first line:

The processing instruction target matching "[xX][mM][lL]" is not allowed.

Upvotes: 1

Views: 1264

Answers (2)

Abdurahman Popal
Abdurahman Popal

Reputation: 3019

<?xml version="1.0" encoding="utf-8"?>

just add the above line at your xml or check if its duplicate there

Upvotes: 1

user3167588
user3167588

Reputation:

You try this codes dependable your need . such as

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

    <item android:drawable="@color/footer_color" android:state_pressed="true"/>
    <item android:drawable="@color/footer_color" android:state_selected="true"/>
    <item android:drawable="@android:color/transparent"/>
    <item android:drawable="@drawable/back_black" android:state_pressed="true"/>
     <item android:drawable="@layout/full_image_screen" android:state_pressed="true"/>

</selector> 

Must be remember that when you access @drawable then must be include drawable image also for layout.

Upvotes: 0

Related Questions