MVXRecyclerView ItemClick无效。
请查看下面的详细信息,并建议是否有需要点击的按钮的列表。
我尝试了所有可能的方法,但我无法解决问题。
模板
<?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')" />
视图模型
public IMvxCommand TimeClickedCommand
{
get
{
return new MvxCommand<FooModel>(param =>
{
Mvx.Resolve<IMvxNavigationService>().Navigate(new FooViewModel(), param);
});
}
}
答案 0 :(得分:0)
尝试将此代码用于TimeClickedCommand
:
private MvxCommand<FooModel> _timeClickedCommand;
public IMvxCommand TimeClickedCommand
{
get
{
_timeClickedCommand = _timeClickedCommand ?? new MvxCommand<FooModel>(Mvx.Resolve<IMvxNavigationService>().Navigate(new FooViewModel()));
return _timeClickedCommand;
}
}