Git Product home page Git Product logo

editspinner's Introduction

EditSpinner

一款可输入文字的spinner

显示效果

USAGE

Gradle

compile 'com.wrbug:editspinner:1.1.0'

Maven

<dependency>
  <groupId>com.wrbug</groupId>
  <artifactId>editspinner</artifactId>
  <version>1.1.0</version>
  <type>pom</type>
</dependency>

更新说明

v1.1.0

  1. 添加item监听
  2. 添加编辑框最大行数
  3. 修复上个版本一个bug(显示列表后点击外部隐藏,需要点击两次才能展示)

布局中添加

    <com.wrbug.editspinner.EditSpinner
        android:id="@+id/editSpinner1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:Background="@drawable/bg_view_frame"
        app:hint="EditSpinner Test"
        app:rightImage="@drawable/ic_expand_more_black" />

快速使用

    spinner1 = (EditSpinner) findViewById(R.id.editSpinner1);
    spinner1.setRightImageResource(R.drawable.ic_expand_more_black);
    spinner1.setHint("EditSpinner");
    spinner2.setItemData(list);  

使用adapter

实现adapter继承BaseEditSpinnerAdapter

public abstract class BaseEditSpinnerAdapter extends BaseAdapter {
    /**
     * editText输入监听
     *
     * @return
     */
    public abstract EditSpinnerFilter getEditSpinnerFilter();

    /**
     * 获取需要填入editText的字符串
     * @param position
     * @return
     */
    public abstract String getItemString(int position);

}
public interface EditSpinnerFilter {
    /**
     * editText输入监听
     * @param keyword
     * @return
     */
    boolean onFilter(String keyword);
}
	public class SimpleAdapter extends BaseEditSpinnerAdapter{
		...
		...
	}

使用setAdapter()方法

	spinner1 = (EditSpinner) findViewById(R.id.editSpinner1);
	SimpleAdapter simpAdapter=new SimpleAdapter(this,list);
	spinner1.setAdapter(simpAdapter);

方法说明

方法/字段 参数类型 说明
setItemData() List 备选字符串
setAdapter() BaseEditSpinnerAdapter /
setText() String 设置文本
setTextColor() int 设置文本颜色
getText() void 获取文本
setHint() String /
setRightImageDrawable() Drawable 设置右边显示
setRightImageResource() int 设置右边显示

License

Copyright 2017, Yalantis

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.

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.