简体   繁体   English

Xamarin.Forms Listview上下文操作适用于Android

[英]Xamarin.Forms Listview Context Actions For Android

In a Xamarin.Forms app on Android, context actions for listview highlights the selected cell in white after longpress and changes the navigation bar so that it includes the options. 在Android上的Xamarin.Forms应用程序中,listview的上下文操作会在longpress后突出显示所选的单元格,并更改导航栏以使其包含选项。 Isn't the default behavior for Android context menu items to appear as a pop-up? Android上下文菜单项的默认行为是否显示为弹出式窗口? As far as I know, showing context actions on the navbar is usually applicable when we can do a multi-select. 据我所知,当我们可以进行多选时,在导航栏上显示上下文操作通常是适用的。 Or even if it is shown for a single selection, there is usually a check mark next to that row rather than having the row highlighted in white. 或者即使它显示为单个选择,通常在该行旁边有一个复选标记,而不是将该行突出显示为白色。 Does anyone know why Xamarin.Forms implemented this in Android as such? 有谁知道为什么Xamarin.Forms在Android中实现了这个? Is there an example of such a use case in any Android app? 在任何Android应用中都有这样一个用例的例子吗? Here is a screenshot from their guide: 以下是他们的指南中的截图:

在此输入图像描述

And finally, how can it be customised for it to follow the default Android behavior? 最后,如何根据默认的Android行为进行自定义?

As you can see on Android ContextActions are implemented through items in the navigation bar. 正如您在Android上看到的, ContextActions是通过导航栏中的项目实现的。 If you want a different behavior, you would have to implement it yourself or use another control. 如果您想要一个不同的行为,您必须自己实现它或使用另一个控件。 Additionally, ContextActions are for a single cell item only - no multi select. 此外, ContextActions仅适用于单个单元格项目 - 无多选。

To find out the real implementation have a look in the source . 要找出真正的实现,请查看源代码

If you don't want a white background you have to adapt the styles. 如果您不想要白色背景,则必须调整样式。 Either with Xamarin.Forms or natively. 使用Xamarin.Forms或本机。 I use native styles here. 我在这里使用原生风格。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM