2025年3月18日 星期二 甲辰(龙)年 月十七 设为首页 加入收藏
rss
您当前的位置:首页 > 计算机 > 编程开发 > 安卓(android)开发

通讯录字母检索功能源码

时间:04-02来源:作者:点击数:36

近期开发需要一个字母检功能,网上找了一个然后进行了修改,现在整理出来分享给大家

一般的例子都会是静态数据,这样不会出现什么问题,但是一旦网络请求回来就会发现可能会有问题,我遇到的问题是网络请求回来之后并没有给每天数据添加标记,因此每次滑动的时候因为找不到标记而崩溃

因此需要在请求回来的数据添加一个标记

  • private void getDate() {
  • SharedHelper sharedHelper;
  • sharedHelper = new SharedHelper(MyApplication.getInstance());
  • ServerApi.queryUserByOrgAndRole(sharedHelper.getUser().getOrgid(), "3,5").subscribe(new BaseSubscriber<List<PeopleBean>>() {
  • @Override
  • public void onNext(List<PeopleBean> value) {
  • ArrayList<PeopleBean> peopleList = new ArrayList<PeopleBean>();
  • for (PeopleBean person : value) {//给每条数据调价一个index
  • person.setIndex(FirstLetterUtil.getFirstLetter(person.getRealname()));
  • peopleList.add(person);
  • }
  • Collections.sort(peopleList, new LetterComparator());
  • mContactModels.addAll(peopleList);
  • mShowModels.addAll(mContactModels);
  • mAdapter.notifyDataSetChanged();
  • }
  • });
  • }
方便获取更多学习、工作、生活信息请关注本站微信公众号城东书院 微信服务号城东书院 微信订阅号
推荐内容
相关内容
栏目更新
栏目热门