• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps android selector focus does not work in listview

aakaa

Lurker
hello I have followed the following tutorial:
HTML:
geekjamboree web site
to build a selector for my program but the state focused does not work and state pressed is working fine I don't know why
any suggestion ?
 
focused is for trackball/d-pad -- is this what you want?

Usually you will want to cover all the states you need like:

Code:
<?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/btn_dash_list_on" />
    <item android:state_focused="true"
        android:drawable="@drawable/btn_dash_list_on" />
    <item android:drawable="@drawable/btn_dash_list_off" />
</selector>

ListViews also have their own item optimizations... you may need to experiment depending on how you are creating the view and handling the click.

Can you post all the code you use in XML and java to interact with the listview and its items (including the adapter if you use one)
 
Back
Top Bottom