質問

In my app I have a ListView with items which have this style:

<style name="GoogleNowCardStyle" parent="android:Widget.TextView">
    <item name="android:background">@drawable/search_bg_shadow</item>
    <item name="android:gravity">center</item>
    <item name="android:minHeight">@dimen/GoogleNowCardMinHeight</item>
    <item name="android:minWidth">200dp</item>
    <item name="android:textColor">#707070</item>
</style>

Now my problem is that I have to select these items in the ListView so I have to add:

android:background="?android:attr/activatedBackgroundIndicator"

to my main ListView item layout. But this line overwrites the background atribute from the style. How can I use both of these at the same time on my ListView items?

役に立ちましたか?

解決

You should probably create a StateList drawable resource that has a state_selected item and use it as a background for your listItem. When the listItem's state changes to selected it will load the drawable that was set for the state_selected item in your state list.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top