多语言获取索引

[api引用地址](https://developer.android.com/reference/android/icu/text/AlphabeticIndex)

   Locale locale = getResources().getConfiguration().getLocales().get(0);//获取语言
        AlphabeticIndex index = new AlphabeticIndex(locale).addLabels(Locale.ENGLISH);//设置当前语言, 增加更多的语言
        index.setUnderflowLabel("#");
//添加数据
        for (MatchListBean.ListBean bean : matchList) {
            if (TextUtils.isEmpty(bean.getLeague())) {
                index.addRecord("#", bean);
            } else {
                index.addRecord(bean.getLeague(), bean);
            }
        }

        List countryBeans = new ArrayList<>();
//获取已经排序好的数据
        for (AlphabeticIndex.Bucket bucket : index) {
            if (bucket.size() != 0) {
                for (AlphabeticIndex.Record item : bucket) {
                    MatchListBean.ListBean matchBean = item.getData();
                    List listBeans = new ArrayList<>();
                    listBeans.add(matchBean);
                    FilterGLTimeBean countryBean = new FilterGLTimeBean(bucket.getLabel(), matchBean.getLeague(), listBeans, true);
                    if (mFilterInputBean.getSelectType() == 1 && mFilterInputBean.getSelectList().size() > 0) {
                        countryBean.setSelect(mFilterInputBean.getSelectList().contains(countryBean));
                    }
                    if (countryBeans.contains(countryBean)) {
                        for (FilterGLTimeBean bean : countryBeans) {
                            if (TextUtils.equals(bean.getName(), countryBean.getName())) {
                                bean.getMatchList().add(matchBean);
                            }
                        }
                    } else {
                        countryBeans.add(countryBean);
                    }
                }
            }
        }

你可能感兴趣的:(多语言获取索引)