如何创建Xamarin跨平台的列表视图粘头?我已经整理对象的列表,我想滚动时创建粘头。
有这个,你可以找到here的GitHub代码
对于iOS,这是本机的行为
和Android渲染低于:
public class CustomListViewRenderer : ViewRenderer<CustomListView, Android.Views.View>
{
Dictionary<string, int> mapIndex;
StickyListHeadersListView SlistView;
protected override void OnElementChanged(ElementChangedEventArgs<CustomListView> e)
{
base.OnElementChanged(e);
LayoutInflater inflater = (LayoutInflater)Context.GetSystemService(Context.LayoutInflaterService);
Android.Views.View v = inflater.Inflate(Resource.Layout.customListView, null, false);
//this.AddView(v);
if (Control == null)
{
SlistView = v.FindViewById<StickyListHeadersListView>(Resource.Id.list_employee);
SetNativeControl(v);
}
if (e.OldElement != null)
{
// unsubscribe
//Control.ItemClick -= OnItemClick;
}
if (e.NewElement != null)
{
// subscribe
SlistView.Adapter = new CustomListViewAdapter(Forms.Context as Android.App.Activity, e.NewElement as CustomListView);
}
}
protected override void OnElementPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{
//base.OnElementPropertyChanged(sender, e);
}
void OnItemClick(object sender, Android.Widget.AdapterView.ItemClickEventArgs e)
{
//((CustomListView)Element).NotifyItemSelected(((CustomListView)Element).Items.ToList()[e.Position - 1]);
}
}
古德勒克在出现问题时随时恢复。