Liste seçici aracılığıyla her Listview öğesine özel bir arka plan uygulamak mümkün müdür?
Varsayılan seçici @android:color/transparent, state_focused="false"durumu belirtir , ancak bunu bazı özel çekilebilir öğeler olarak değiştirmek, seçilmeyen öğeleri etkilemez. Romain Guy bu yanıtta bunun mümkün olduğunu öne sürüyor gibi görünüyor .
Şu anda aynı etkiyi her görünümde özel bir arka plan kullanarak ve öğe seçildiğinde / odaklandığında / her ne olursa olsun gizleyerek elde ediyorum, bu nedenle seçici gösterilir, ancak bunların hepsinin tek bir yerde tanımlanması daha zarif olur.
Referans olarak, bu çalışmayı denemek için kullandığım seçici:
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_focused="false"
android:drawable="@drawable/list_item_gradient" />
<!-- Even though these two point to the same resource, have two states so the drawable will invalidate itself when coming out of pressed state. -->
<item android:state_focused="true" android:state_enabled="false"
android:state_pressed="true"
android:drawable="@drawable/list_selector_background_disabled" />
<item android:state_focused="true" android:state_enabled="false"
android:drawable="@drawable/list_selector_background_disabled" />
<item android:state_focused="true" android:state_pressed="true"
android:drawable="@drawable/list_selector_background_transition" />
<item android:state_focused="false" android:state_pressed="true"
android:drawable="@drawable/list_selector_background_transition" />
<item android:state_focused="true"
android:drawable="@drawable/list_selector_background_focus" />
</selector>
Seçiciyi şu şekilde ayarlıyorum:
<ListView
android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:listSelector="@drawable/list_selector_background" />
Herhangi bir yardım için şimdiden teşekkürler!