在 Android 上 ListView 快速滚动ListView Fast Scrolling on Android
07/10/2018
本文内容
此 Android 平台特定用于启用快速滚动查看中的数据 ListView 。This Android platform-specific is used to enable fast scrolling through data in a ListView. 它通过将 ListView.IsFastScrollEnabled 附加属性设置为值在 XAML 中使用 boolean :It's consumed in XAML by setting the ListView.IsFastScrollEnabled attached property to a boolean value:
xmlns:android="clr-namespace::::no-loc(Xamarin.Forms):::.PlatformConfiguration.AndroidSpecific;assembly=:::no-loc(Xamarin.Forms):::.Core">
...
GroupDisplayBinding="{Binding Key}"
IsGroupingEnabled="true"
android:ListView.IsFastScrollEnabled="true">
...
此外,还可以使用 Fluent API 从 c # 使用该方法:Alternatively, it can be consumed from C# using the fluent API:
using :::no-loc(Xamarin.Forms):::.PlatformConfiguration;
using :::no-loc(Xamarin.Forms):::.PlatformConfiguration.AndroidSpecific;
...
var listView = new :::no-loc(Xamarin.Forms):::.ListView { IsGroupingEnabled = true, ... };
listView.SetBinding(ItemsView.ItemsSourceProperty, "GroupedEmployees");
listView.GroupDisplayBinding = new Binding("Key");
listView.On().SetIsFastScrollEnabled(true);
ListView.On方法指定此平台特定的仅在 Android 上运行。The ListView.On method specifies that this platform-specific will only run on Android. The ListView.SetIsFastScrollEnabled method, in the :::no-loc(Xamarin.Forms):::.PlatformConfiguration.AndroidSpecific namespace, is used to enable fast scrolling through data in a ListView. 此外, SetIsFastScrollEnabled 通过调用方法返回快速滚动是否启用,方法可用于切换快速滚动 IsFastScrollEnabled :In addition, the SetIsFastScrollEnabled method can be used to toggle fast scrolling by calling the IsFastScrollEnabled method to return whether fast scrolling is enabled:
listView.On().SetIsFastScrollEnabled(!listView.On().IsFastScrollEnabled());
结果是,可以在中快速滚动浏览数据 ListView ,这将更改滚动块的大小:The result is that fast scrolling through data in a ListView can be enabled, which changes the size of the scroll thumb:
相关链接Related links