Comment changer la couleur d'arrière-plan d'un MvxItemTemplate?Modifier la couleur d'arrière-plan de MvxItemTemplate?
Je peux changer l'arrière-plan de MvxListView, mais cela change l'arrière-plan de tous les éléments.
Voici le code correspondant:
<MvvmCross.Binding.Droid.Views.MvxListView
android:id="@+id/favoritesList"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
local:MvxItemTemplate="@layout/template_screen"
local:MvxBind="ItemsSource FavoritesGroupedList; ItemClick ScreenSelectedCommand; ItemLongClick ShowUnFavoriteCommand" />
Si je place BackgroundColor BlackOrBlueColor(IsUnFavorite)
dans le local: MvxBind pour le ListView, cela fonctionne. J'ai essayé de placer la reliure dans mon modèle:
?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:local="http://schemas.android.com/apk/res-auto"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<TextView
android:id="@+id/screenIcon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginRight="10dp"
android:layout_marginBottom="10dp"
android:layout_marginTop="10dp"
local:MvxBind="BackgroundColor BlackOrBlueColor(IsUnFavorite)"/>
<TextView
android:id="@+id/screenText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginTop="10dp" />
</LinearLayout>
Mais cela ne fonctionne pas.
Je l'ai essayé et cela ne change pas la couleur d'arrière-plan. J'ai une liste et je veux que l'utilisateur puisse sélectionner plusieurs éléments à supprimer. Si l'élément est contenu dans la liste des éléments à supprimer, je veux qu'il soit surligné afin que l'utilisateur sache ce qu'il supprime. Cela ajoute-t-il des éclaircissements? –
Vous devez créer un ColorStateList: https://developer.android.com/reference/android/content/res/ColorStateList.html –