Giter Club home page Giter Club logo

wavesidebar's Introduction

WaveSideBar

WavaSideBar——一个自带中英文对应排序和检索功能的字母导航栏 ##效果图

⊙开源不易,希望给个star或者fork奖励

特点

1、支持手势滑动导航栏
2、支持自定义设置偏移量和颜色
3、支持设置字母导航栏设置位置
4、支持自动匹配中英文
5、支持拼音和中文搜索

使用方法

1、添加依赖

2017年1月5日后仓库转移到jitpack,添加依赖方式为:

Step 1. Add it in your root build.gradle at the end of repositories:
allprojects {
		repositories {
			...
			maven { url 'https://jitpack.io' }
		}
	}
Step 2. Add the dependency
dependencies {
	        compile 'com.github.nanchen2251:WaveSideBar:1.0.6'
	}

2、在xml文件里面使用

  <!--搜索框-->
  <com.nanchen.wavesidebar.SearchEditText
        android:id="@+id/main_search"
        android:layout_width="match_parent"
        android:layout_height="40dp"
        android:layout_marginLeft="15dp"
        android:layout_marginRight="15dp"
        android:layout_marginTop="5dp"
        android:background="@drawable/search_edit_bg"
        android:drawableLeft="@mipmap/icon_search"
        android:drawablePadding="5dp"
        android:drawableStart="@mipmap/icon_search"
        android:gravity="center_vertical"
        android:hint="@string/search"
        android:imeOptions="actionSearch"
        android:maxLines="1"
        android:padding="5dp"
        android:textSize="16sp"
        app:drawableDel="@mipmap/edit_delete"/>
	
	
  <!--字母导航栏-->
  <com.nanchen.wavesidebar.WaveSideBarView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:padding="8dp"
        android:id="@+id/main_side_bar"
        app:sidebar_text_color="@color/colorAccent"
        app:sidebar_lazy_respond="false"/>

3、在Activity里面使用

    mWaveSideBarView = (WaveSideBarView) findViewById(R.id.main_side_bar);
    mWaveSideBarView.setOnSelectIndexItemListener(new OnSelectIndexItemListener() {
        @Override
        public void onSelectIndexItem(String letter) {
            for (int i=0; i<mContactModels.size(); i++) {
                if (mContactModels.get(i).getIndex().equals(letter)) {
                    ((LinearLayoutManager) mRecyclerView.getLayoutManager()).scrollToPositionWithOffset(i, 0);
                    return;
                }
            }
        }
    });
    
    // 搜索按钮相关
        mSearchEditText = (SearchEditText) findViewById(R.id.main_search);
        mSearchEditText.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {

            }

            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {

            }

            @Override
            public void afterTextChanged(Editable s) {
	        //You can do something in there
                mShowModels.clear();
                for (ContactModel model : mContactModels) {
                    String str = Trans2PinYinUtil.trans2PinYin(model.getName());
                    if (str.contains(s.toString())|| model.getName().contains(s.toString())) {
                        mShowModels.add(model);
                    }
                }
                mAdapter.notifyDataSetChanged();
            }
        });

4、自动匹配中英文

FirstLetterUtil.getFirstLetter(name);

5、中文转换成拼音

Trans2PinYinUtil.trans2PinYin(String name);

具体请下载查看示例代码

属性一览

Attributes Format Default Description
sidebar_text_color color Color.GRAY Text color.
sidebar_max_offset dimension 80dp Offset of the selected item.
sidebar_position enum {right, left} right Be placed on left or right in the view.
sidebar_text_alignment enum {center, left, right} center Alignment of items.
sidebar_lazy_respond boolean false If true, the listener will not be called until the finger up. If false, the listener will be called when the finger down, move and up.

该项目参考了:

关于作者

   南尘
   四川成都
   其它开源
   博客园

wavesidebar's People

Contributors

nanchen2251 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.