Giter Site home page Giter Site logo

objectspinner's Introduction

API LICENSE

Object Spinner (Searchable)

ObjectSpinner is an Android spinner library for object selection and supports searching.



Download Download

Download the latest AAR or grab via Gradle:

implementation 'kr.ry4nkim:objectspinner:1.0.1'

or Maven:

<dependency>
  <groupId>kr.ry4nkim</groupId>
  <artifactId>objectspinner</artifactId>
  <version>1.0.1</version>
  <type>pom</type>
</dependency>

Usage

  1. Add the ObjectSpinner to your layout XML:
<kr.ry4nkim.objectspinner.ObjectSpinner
    android:id="@+id/spinner"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"/>
  1. Implement ObjectSpinner.Delegate on your object to override the getSpinnerDelegate() method to return the spinner's delegate:
public class YourObject implements ObjectSpinner.Delegate {
  private String mCode;
  private String mName;
  ...

  @Override
  public String getSpinnerDelegate() {
    return mName;
  }
  ...
}
  1. Add item list to the spinner and listen for select:
ObjectSpinner<YourObject> mObjectSpinner = findViewById(R.id.spinner);

List<YourObject> itemList = new ArrayList<>();

itemList.add(new YourObject("obj0001", "Object 1"));
itemList.add(new YourObject("obj0002", "Object 2"));
itemList.add(new YourObject("obj0003", "Object 3"));

mObjectSpinner.setItemList(itemList);

mObjectSpinner.setOnItemSelectedListener((view, position, item) -> {
  Snackbar.make(view, "Selected Object : " + item, Snackbar.LENGTH_SHORT).show();
});

mObjectSpinner.setOnNothingSelectedListener(view -> {
  Log.i(TAG, "onNothingSelected");
});

You can add attributes to customize the view. Available attributes:

name type info
os_padding dimension set the padding of the spinner
os_padding_left dimension set the left padding of the spinner
os_padding_top dimension set the top padding of the spinner
os_padding_right dimension set the right padding of the spinner
os_padding_bottom dimension set the bottom padding of the spinner
os_text_size dimension set the text size of the spinner
os_text_color color set the text color of the spinner
os_background_color color set the background color of the spinner
os_hint string set the hint of the spinner
os_hint_color color set the hint color of the spinner
os_arrow_color color set the arrow color of the spinner
os_shadow boolean set to false to hide the shadow of the spinner
os_list_max_height dimension set the max height of the spinner list
os_list_empty_text string set the empty list text of the spinner list
os_item_padding dimension set the padding of the spinner item
os_item_padding_left dimension set the left padding of the spinner item
os_item_padding_top dimension set the top padding of the spinner item
os_item_padding_right dimension set the right padding of the spinner item
os_item_padding_bottom dimension set the bottom padding of the spinner item
os_item_text_size dimension set the text size of the spinner item
os_item_text_color color set the text color of the spinner item
os_item_background_color color set the background color of the spinner item
os_selected_item_text_size dimension set the padding of the spinner selected item
os_selected_item_text_color color set the padding of the spinner selected item
os_selected_item_background_color color set the padding of the spinner selected item
os_search_text_color color set the search text color of the spinner
os_search_icon_color color set the search icon color of the spinner
os_search_background_color color set the search background color of the spinner
os_searchable boolean set to false to hide the search of the spinner

Acknowledgements

Material Spinner by Jared Rummler

License

Copyright (C) 2019 ry4nkim

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.

objectspinner's People

Contributors

ry4nkim 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.