2012-12-03 1 views
1

j'utilisais un MvxBindableGridView dans une disposition relative et il fonctionnait parfaitement. J'ai alors réalisé que je devais utiliser LinearLayouts pour mes écrans afin de les adapter correctement à différents appareils. Quand je l'ai changé à un LinearLayout et exécuter l'application GridView est vide et la sortie de débogage montre quelques erreurs de liaisonMvxBindableGridView dans une impasse doesnt LinearLayout à tous les articles

12-03 16:55:38.363 I/MvxBind (2689): 14.25 Failed to create target binding for from ClickCommand to ClickItemSquare 
MvxBind:Warning: 14.25 Failed to create target binding for from ClickCommand to ClickItemSquare 
12-03 16:55:38.363 I/mono-stdout(2689): MvxBind:Warning: 14.25 Failed to create target binding for from ClickCommand to ClickItemSquare 

Est-ce que quelqu'un sait pourquoi cela a échoué quand il fonctionne parfaitement dans RelativeLayout?

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:local="http://schemas.android.com/apk/res/xxxxx" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent"> 
<RelativeLayout 
    android:id="@+id/layoutresults" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content"> 
    <TextView 
     android:id="@+id/textscore" 
     local:MvxBind="{'Text':{'Path':'Score'}}" 
     android:layout_width="50dp" 
     android:layout_height="wrap_content" 
     android:text="0000" 
     android:textColor="#ff60350f" 
     android:textSize="20dp" 
     android:layout_x="25dp" 
     android:layout_y="45dp" 
     android:textStyle="bold" 
     android:gravity="center" 
     android:layout_marginTop="53dp" 
     android:layout_marginLeft="25dp" /> 
    <TextView 
     android:id="@+id/layoutstartnewgame" 
     android:layout_width="100dp" 
     android:layout_height="65dp" 
     android:layout_x="109dp" 
     android:layout_y="23dp" 
     android:textStyle="bold" 
     local:MvxBind="{'Click':{'Path':'StartNewGame'}}" 
     android:layout_centerHorizontal="true" 
     android:layout_marginTop="27dp" /> 
    <TextView 
     android:id="@+id/texttime" 
     local:MvxBind="{'Text':{'Path':'Time'}}" 
     android:text="00:00" 
     android:textColor="#ff60350f" 
     android:textSize="20dp" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_x="245dp" 
     android:layout_y="45dp" 
     android:textStyle="bold" 
     android:layout_marginTop="53dp" 
     android:layout_alignParentRight="true" 
     android:layout_marginRight="23dp" /> 
</RelativeLayout> 
<cirrious.mvvmcross.binding.android.views.MvxBindableGridView 
    android:layout_below="@+id/layoutresults" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:numColumns="4" 
    android:gravity="center" 
    android:listSelector="#00000000" 
    local:MvxItemTemplate="@layout/itemimage" 
    local:MvxBind="{'ItemsSource':{'Path':'Squares'}, 'ClickItemSquare':{'Path':'ClickCommand'}}" 
    android:layout_marginTop="8dp" /> 
</RelativeLayout> 

à Changé Linear

<?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/xxxxx" 
android:orientation="vertical" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:background="@drawable/TabletGameScreen"> 
<LinearLayout 
    android:layout_width="fill_parent" 
    android:orientation="vertical" 
    android:layout_weight=".1" 
    android:gravity="center" /> 
<LinearLayout 
    android:id="@+id/layoutresults" 
    android:orientation="horizontal" 
    android:gravity="center_vertical" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:layout_weight=".1"> 
    <TextView 
     android:id="@+id/textscore" 
     local:MvxBind="{&apos;Text&apos;:{&apos;Path&apos;:&apos;Score&apos;}}" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:text="0000" 
     android:textColor="#ff60350f" 
     android:textSize="20dp" 
     android:textStyle="bold" 
     android:gravity="center_horizontal" 
     android:layout_gravity="center_vertical" /> 
    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="fill_parent" 
     android:layout_weight="1" 
     android:textStyle="bold" 
     local:MvxBind="{&apos;Click&apos;:{&apos;Path&apos;:&apos;StartNewGame&apos;}}" 
     android:layout_centerHorizontal="true" 
     android:layout_gravity="center_vertical" /> 
    <TextView 
     android:id="@+id/texttime" 
     local:MvxBind="{&apos;Text&apos;:{&apos;Path&apos;:&apos;Time&apos;}}" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:text="00:00" 
     android:textColor="#ff60350f" 
     android:textSize="20dp" 
     android:textStyle="bold" 
     android:layout_gravity="center_vertical" 
     android:gravity="center_horizontal" /> 
</LinearLayout> 
<cirrious.mvvmcross.binding.android.views.MvxBindableGridView 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:layout_weight=".8" 
    android:numColumns="4" 
    android:gravity="center" 
    android:listSelector="#00000000" 
    local:MvxItemTemplate="@layout/itemimage" 
    local:MvxBind="{&apos;ItemsSource&apos;:{&apos;Path&apos;:&apos;Squares&apos;}, &apos;ClickItemSquare&apos;:{&apos;Path&apos;:&apos;ClickCommand&apos;}}" /> 
</LinearLayout> 
+0

Pouvez-vous fournir plus de code que cela? Par exemple. Exact avant et après de ce qui a fonctionné et non? – Stuart

Répondre

1

Les avertissements ClickItemSquare vous disent que certains de liaison qui se passe, mais que le ClickCommand ne fonctionne pas.

Sur la base de ce que peu d'informations, il est dans votre question ...

  • Regardez comment ClickCommand est mis en œuvre - je suppose qu'il est basé sur Return ImageView instance when i click on the item GridView - mais il est votre code pour que personne ne peut aider les autres vous avec elle (à moins que vous publiez)
  • Essayez de régler le niveau de trace se liant à verbeux/diagnostic pour obtenir plus d'informations sur (regarder MvxBindingTrace pour savoir comment faire - il y a une valeur variable statique pour définir)
  • Vérifier que vous avez android: orientation = 'verticale' à votre LinearLayout
  • Essayez de parcourir le code: les valeurs de propriété des éléments de la liste ViewModel sont-elles appelées? Si elles sont alors vous savez liaison travaille
  • Essayez de revenir en arrière au code de la grille - vous voyez les mêmes avertissements ClickItemSquare
  • Essayez de poster une question avec plus de détails sur les changements (par exemple, certains avant et après le code)
+0

Ive a ajouté le code à l'article original pour que vous puissiez regarder. Maintenant, ce qui est intéressant sur la version LinearLayout si je change le niveau supérieur LinearLayout à un RelativeLayout il affiche et encore travailler, mais je ne peux pas obtenir la mise en page comme il devait être maintenant. – mdev

+0

Il s'avère que c'était un cas de concepteur Android ne montrant pas la même chose que ce que vous obtenez réellement. On dirait que la vue de la grille était la voie de l'écran. Je suis revenu à la version LinearLayout et je l'ai récupéré sur l'écran en modifiant certains des attributs de taille pour ne pas remplir fill_parent. Je ne sais pas pourquoi les erreurs de liaison ne se sont produites que lorsque la grille était hors de vue, mais bon, nous avons au moins une réponse. – mdev

Questions connexes