MvxGridView ItemClick 未触发

MvxGridView ItemClick not Firing

我正在努力做一些看似微不足道的事情。

我有一个像这样的 MvxGridView

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:app="http://schemas.android.com/apk/res-auto"
  android:orientation="vertical"
  android:layout_width="match_parent"
  android:layout_height="match_parent">

  <Mvx.MvxGridView
    android:id="@+id/subjects_gv"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:choiceMode="singleChoice"
    android:numColumns="2"
    android:verticalSpacing="15dp"
    android:gravity="center"
    app:MvxItemTemplate="@layout/assigned_subject_view"
    app:MvxBind="ItemClick ShowSubjectFeatures;ItemsSource Subjects;"/>
</LinearLayout>

这是模板

<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView
  xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:local="http://schemas.android.com/apk/res-auto"
  xmlns:tools="http://schemas.android.com/tools"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:clickable="true"
  local:cardUseCompatPadding="true"
  local:cardCornerRadius="5dp">

  <RelativeLayout
    android:layout_width="150dp"
    android:layout_height="150dp"
    android:layout_gravity="center"
    android:orientation="vertical"
    android:clickable="true"
    android:background="?android:attr/selectableItemBackground">
    <ImageView
      android:layout_centerInParent="true"
      android:id="@+id/iv_subject_image"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:src="@drawable/english" />
    <TextView
      android:layout_centerInParent="true"
      android:layout_alignParentBottom="true"
      android:id="@+id/tv_subject_Name"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:textAllCaps="true"
      android:gravity="center"
      android:maxLines="2"
      android:stretchMode="spacingWidthUniform"
      android:textSize="@dimen/very_small_text"
      local:MvxBind="Text Name" />
  </RelativeLayout>

</android.support.v7.widget.CardView>

这是视图模型

private readonly IMvxNavigationService _navigationService;
        private readonly ISubjectsService _subjectsService;

        public SubjectsViewModel(IMvxNavigationService navigationService, ISubjectsService subjectsService)
        {
            _navigationService = navigationService;
            _subjectsService = subjectsService;
        }

        public MvxObservableCollection<SubjectModel> Subjects { get; set; } = new MvxObservableCollection<SubjectModel>();

        public MvxCommand<SubjectModel> ShowSubjectFeatures
        {
            get
            {
                // Navigate to subject details viewmodel
                return new MvxCommand<SubjectModel>(async subject => await NavigateToFeatures(subject));
            }
        }

        public override async Task Initialize()
        {
            var response = await _subjectsService.GetAssignedSubjects();
            Subjects.AddRange(response.Subjects);
        }

        private async Task NavigateToFeatures(SubjectModel model)
        {
            await _navigationService.Navigate<SubjectFeatureViewModel, int>(model.Id);
        }

问题是当我单击网格项时未触发命令。 其他信息,gridview 显示在一个片段中,而 SubjectFeaureView 也是一个片段,因此它将从一个片段导航到另一个片段。我不认为这应该是一个问题,不过。我错过了什么?我对此很陌生。

删除 android:clickable="true" 解决了我的问题。