【问题标题】:RecyclerView with Alphabet indext in xamarin android在xamarin android中具有字母索引的RecyclerView
【发布时间】:2020-06-04 05:37:30
【问题描述】:

谁能帮我解决这个问题我想在 Xamarin android 中使用 Recyclerview 实现字母索引。

【问题讨论】:

标签: xamarin.android


【解决方案1】:

您必须先对我们的列表进行排序

示例:

 List<Email> emails = new List<Email>();
    emails.Add(new Email { Address="Test1@contoso.com" , CreateTime=new DateTime(2016, 7, 14, 3, 15, 0) });
    emails.Add(new Email { Address = "Test2@contoso.com", CreateTime = new DateTime(2013, 8, 11, 3, 15, 0) });
    emails.Add(new Email { Address = "Test3@contoso.com", CreateTime = new DateTime(2017, 6, 13, 3, 15, 0) });
    emails.Add(new Email { Address = "Test4@contoso.com", CreateTime = new DateTime(2011, 8, 14, 3, 15, 0) });
    emails.Add(new Email { Address = "Test5@contoso.com", CreateTime = new DateTime(2013, 9, 16, 3, 15, 0) });
    emails.Add(new Email { Address = "Test6@contoso.com", CreateTime = new DateTime(2015, 1, 15, 3, 15, 0) });

    emails.Sort((x, y) => DateTime.Compare(x.CreateTime, y.CreateTime));

    var recyclerView = FindViewById<RecyclerView>(Resource.Id.recyclerView);
    RecyclerViewAdapter adapter = new RecyclerViewAdapter(emails, this);
    recyclerView.SetLayoutManager(new LinearLayoutManager(this));
    recyclerView.SetAdapter(adapter);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-04-07
    • 1970-01-01
    • 2016-11-25
    • 1970-01-01
    • 2016-12-08
    相关资源
    最近更新 更多