androidxamarinmvvmcrossmvxbind

When nested MvxGridView, its Itemclick doesn't work


I use Xamarin + MvvmCross to build an android app.

I have a view where has a MvxGridView, and in its ItemTemplate the child view has another MvxGridView.

In the first MvxGridView has ItemClick event, but it doesn't work. I have tried if I removed the second MvxGridView. The ItemClick works.

This is the first view.

<Mvx.MvxGridView
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    local:MvxBind="ItemsSource Follows; ItemClick GoToEditCommand"
    local:MvxItemTemplate="@layout/item_view"
    android:numColumns="@integer/item_columns"
    android:stretchMode="columnWidth"
    android:horizontalSpacing="5dp"
    android:verticalSpacing="5dp"
    android:gravity="center"
    android:fastScrollEnabled="true"
    android:scrollbars="vertical"
    android:scrollbarStyle="outsideInset"
    android:smoothScrollbar="true"
    android:paddingTop="5dp"
    android:paddingRight="5dp"
    android:paddingBottom="5dp"
    android:paddingLeft="5dp"
    android:drawSelectorOnTop="true"
    android:clipChildren="false"
    android:clipToPadding="false"
    android:clickable="true"
    android:descendantFocusability="beforeDescendants" />

This is the item view.

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:local="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">

<TextView android:text="Information A"/>
<TextView android:text="Information B"/>
<Mvx.MvxGridView
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    local:MvxBind="ItemsSource Lines"
    local:MvxItemTemplate="@layout/item_Icon"
    android:numColumns="6" /></LinearLayout>

This is Item_Icon View

<MvxImageView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:local="http://schemas.android.com/apk/res-auto"
local:MvxBind="DrawableName Id, Converter=IdToImagePath;"
android:layout_width="12dp"
android:layout_height="12dp"
android:layout_margin="1dp"    
android:clickable="false"
android:longClickable="false"
android:focusable="false"
android:focusableInTouchMode="false" />

I have been troubled about a whole day. I have tried a lot methods, like android:descendantFocusability="beforeDescendants", but no method can solve the problems.

How can I do?


Solution

  • It seems like a complex hierarchy. Can you try making this in your gridview ?

    android:descendantFocusability="blocksDescendants"
    

    If it do not work on the main gridview try to remove it from there and put it to itemviews parent LinearLayout.