EasySideBar

一款按字母排序库,已封装好城市数据,风格仿美团,可定制化强。

  • 所有者: Bigkoo/EasySideBar
  • 平台:
  • 许可证:
  • 分类:
  • 主题:
  • 喜欢:
    0
      比较:

Github星跟踪图

EasySideBar

一款按字母排序的库,已封装好城市数据,可定制化强,也可以下载源代码用Module的形式引入自己改一改来使用,也可稍做改造定制成通讯录。欢迎Star、提建议、提Issue。

EasySideBar.gif

使用步骤:

1.添加Jcenter仓库 Gradle依赖:

compile 'com.contrarywind:EasySideBar:1.1.0'

2.在Activity中添加如下代码:


//热门城市数据 ,不添加数据的时候会隐藏该布局
ArrayList<String> hotCityList = new ArrayList<>();
                hotCityList.add("北京");
                hotCityList.add("上海");
                hotCityList.add("广州");
                hotCityList.add("深圳");
                hotCityList.add("杭州");
                hotCityList.add("成都");
                hotCityList.add("厦门");
                hotCityList.add("天津");
                hotCityList.add("武汉");
                hotCityList.add("长沙");
                
//初始化以及配置
new EasySideBarBuilder(MainActivity.this)
                        .setTitle("城市选择")
                        /*.setIndexColor(Color.BLUE)*/
                        .setIndexColor(0xFF0095EE)
                        /*.isLazyRespond(true) //懒加载模式*/
                        .setHotCityList(hotCityList)//热门城市列表
                        .setIndexItems(mIndexItems)//索引字母
                        .setLocationCity("广州")//定位城市
                        .setMaxOffset(60)//索引的最大偏移量
                        .start();

3.在Activity中重写onActivityResult方法,接收回调数据:


    //resultCode 是使用封装好的EasySideBarBuilder.CODE_SIDEREQUEST
    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        switch (requestCode) {
            case EasySideBarBuilder.CODE_SIDEREQUEST:
             if (data!=null){
                 String city = data.getStringExtra("selected");
                 Toast.makeText(this,"选择的城市:"+city,Toast.LENGTH_SHORT).show();
             }
                break;

            default:
                break;
        }

        }

Thanks

License

Copyright 2014 Bigkoo
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

主要指标

概览
名称与所有者Bigkoo/EasySideBar
主编程语言Java
编程语言Java (语言数: 1)
平台
许可证
所有者活动
创建于2017-03-09 05:25:08
推送于2019-08-05 10:30:29
最后一次提交2019-08-05 18:30:28
发布数0
用户参与
星数177
关注者数7
派生数45
提交数28
已启用问题?
问题数5
打开的问题数3
拉请求数0
打开的拉请求数0
关闭的拉请求数0
项目设置
已启用Wiki?
已存档?
是复刻?
已锁定?
是镜像?
是私有?