MvvmCross List - 单击项目和项目中的按钮
MvvmCross List - Click on item and button in item
我尝试使用行项目中的按钮执行不同操作的列表,然后点击项目列表。
这是列表
<Mvx.MvxListView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/RecapResponsesListView"
local:MvxBind="ItemsSource ReponsesRecapList; ItemClick GoToLandscapeQuestion;"
local:MvxItemTemplate="@layout/item_response" />
这是项目回复:
[...]
<Button
android:id="@+id/ResponseValidate"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="20"
android:layout_gravity="center"
android:gravity="center"
android:text="Valider"
local:MvxBind="Click ConfirmResponseCommand; Enabled ConfirmButtonEnabled" />
</LinearLayout>
我的按钮工作正常,我可以毫无问题地点击它,但是自从我添加了它之后,ItemClick 就不再起作用了。我可以从项目中删除我的按钮,然后 ItemClick 再次工作,所以不是这个点击的实现没有。我想添加一个按钮来阻止项目点击...
您对为什么会这样以及如何解决这个问题有什么想法吗??
谢谢!
这实际上不是 MvvmCross 问题,而是焦点问题以及后代如何在 Android 上接收触摸事件。
您应该可以通过添加
来解决您的问题
android:descendantFocusability="blocksDescendants"
使用您的按钮添加到容器中。或者,如果按钮不是 ImageButton
,则只需添加
就足够了
android:focusable="false"
android:focusableInTouchMode="false"
到您的按钮声明。
我尝试使用行项目中的按钮执行不同操作的列表,然后点击项目列表。
这是列表
<Mvx.MvxListView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/RecapResponsesListView"
local:MvxBind="ItemsSource ReponsesRecapList; ItemClick GoToLandscapeQuestion;"
local:MvxItemTemplate="@layout/item_response" />
这是项目回复:
[...]
<Button
android:id="@+id/ResponseValidate"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="20"
android:layout_gravity="center"
android:gravity="center"
android:text="Valider"
local:MvxBind="Click ConfirmResponseCommand; Enabled ConfirmButtonEnabled" />
</LinearLayout>
我的按钮工作正常,我可以毫无问题地点击它,但是自从我添加了它之后,ItemClick 就不再起作用了。我可以从项目中删除我的按钮,然后 ItemClick 再次工作,所以不是这个点击的实现没有。我想添加一个按钮来阻止项目点击...
您对为什么会这样以及如何解决这个问题有什么想法吗??
谢谢!
这实际上不是 MvvmCross 问题,而是焦点问题以及后代如何在 Android 上接收触摸事件。
您应该可以通过添加
来解决您的问题android:descendantFocusability="blocksDescendants"
使用您的按钮添加到容器中。或者,如果按钮不是 ImageButton
,则只需添加
android:focusable="false"
android:focusableInTouchMode="false"
到您的按钮声明。