我使用MvvmCross和Xamarin。在我的应用程序中,我有一个带有嵌套MvxLinearLayout的MvxListView。如何处理LinearLayout项目的点击?
这是我的代码:
HTe列表视图:
列表
<MvxListView
android:id="@+id/category_list"
android:orientation="vertical"
android:choiceMode="singleChoice"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:listSelector="@drawable/list_item_selector"
local:MvxItemTemplate="@layout/listitem_inner_category_list"
local:MvxBind="ItemsSource Source" />
内部清单
<?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-auto"
android:layout_marginTop="20dp"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:layout_marginLeft="3dp"
android:textAppearance="?android:attr/textAppearanceMedium"
local:MvxBind="Text Key" />
<Mvx.MvxLinearLayout
android:id="@+id/inner_category_list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:clickable="true"
local:MvxItemTemplate="@layout/listitem_category"
local:MvxBind="ItemsSource .;ItemClick EditCommand" />
</LinearLayout>
项目:
<?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-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"
android:paddingLeft="6dp"
android:paddingRight="6dp"
android:layout_marginTop="4dp"
android:translationZ="3dp">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:layout_marginBottom="4dp"
android:gravity="fill_horizontal"
android:textAppearance="?android:attr/textAppearanceLarge"
local:MvxBind="Text Name" />
</LinearLayout>
答案 0 :(得分:0)
我在内部列表中使用了这个:
<MvvmCross.Droid.Support.V7.RecyclerView.MvxRecyclerView
android:id="@+id/inner_category_list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:clickable="true"
local:MvxItemTemplate="@layout/listitem_category"
local:MvxBind="ItemsSource .;ItemClick ItemClickCommand" />
它表明在MvxLinearLayout上没有实现ItemClick:)