0

MVXRecyclerView ItemClick is not working.

Please have look into below detail and suggest if list having button which require click.

I tried all possible ways but I'm unable to catch the issue.

Template

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:local="http://schemas.android.com/apk/res-auto"
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content">
    <Button
        android:id="@+id/timeSlotBtn"
        android:layout_height="29dp"
        android:layout_width="76dp"
        android:layout_marginLeft="7dp"
        android:textSize="14sp"
        android:textColor="@android:color/white"
        android:background="@drawable/button_roundedbutton"
        android:focusable="false"
        android:focusableInTouchMode="false"
        local:MvxBind="Text StartTime, Converter=TimeSlotDate;Typeface StringToFont('Effra_Rg')" />
</FrameLayout>

RecyclerView

<MvvmCross.Droid.Support.V7.RecyclerView.MvxRecyclerView
                        android:id="@+id/timeslotsRecyclerView"
                        android:scrollbars="horizontal"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="6dp"
                        android:layout_marginBottom="19dp"
                        android:layout_marginLeft="2dp"
                        android:dividerHeight="0dp"
                        android:divider="@null"
                        local:MvxItemTemplate="@layout/button_item_template"
                        local:MvxBind="ItemClick TimeClickedCommand; Visibility ShowTimeSlotList;Typeface StringToFont('Effra_Rg')" />

ViewModel

public IMvxCommand TimeClickedCommand
        {
            get
            {
                return new MvxCommand<FooModel>(param =>
                {
                    Mvx.Resolve<IMvxNavigationService>().Navigate(new FooViewModel(), param);
                });
            }
        }
Ahmed Ashour
  • 5,179
  • 10
  • 35
  • 56
Chanki
  • 165
  • 13

1 Answers1

0

Try to use this code for your TimeClickedCommand:

private MvxCommand<FooModel> _timeClickedCommand;

public IMvxCommand TimeClickedCommand
{
    get
    {
        _timeClickedCommand = _timeClickedCommand ?? new MvxCommand<FooModel>(Mvx.Resolve<IMvxNavigationService>().Navigate(new FooViewModel()));
        return _timeClickedCommand;
    }
}
Micer
  • 8,731
  • 3
  • 79
  • 73