Giter Club home page Giter Club logo

multispinner's Introduction

MultiSpinner

Download Build Status

Android Spinner Widget with multi selectable list

Overview

MultiSpinner is a class with can be used by Android developers that need a spinner widget with multi selection capabilities. When the user touches on the spinner widget a dialog pops up with a checkbox list.

Spinner with single selection

Spinner item selection dialog

Spinner with multiple selection

Usage

Integrating the widget is quite simple. In your layout.xml add the following snippet:

...
<com.thomashaertel.widget.MultiSpinner
    android:id="@+id/spinnerMulti"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" />
...

After inserting the widget in your layout add the following code to your activity:

   public class MyActivity extends Activity {
       private MultiSpinner spinner;
       private ArrayAdapter<String> adapter;

       @Override
       protected void onCreate(Bundle savedInstanceState) {
           super.onCreate(savedInstanceState);
           setContentView(R.layout.activity_main);
    
           // create spinner list elements
           adapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item);
           adapter.add("Item1");
           adapter.add("Item2");
           adapter.add("Item3");
           adapter.add("Item4");
           adapter.add("Item5");
    
           // get spinner and set adapter
           spinner = (MultiSpinner) findViewById(R.id.spinnerMulti);
           spinner.setAdapter(adapter, false, onSelectedListener);
    
           // set initial selection
           boolean[] selectedItems = new boolean[adapter.getCount()];
           selectedItems[1] = true; // select second item
           spinner.setSelected(selectedItems);
       }

       private MultiSpinner.MultiSpinnerListener onSelectedListener = new MultiSpinner.MultiSpinnerListener() {
           public void onItemsSelected(boolean[] selected) {
               // Do something here with the selected items
           }
       };
   }

Building

Gradle

From Bintray

Add maven central to your build.gradle:

buildscript {
  repositories {
    jcenter()
  }
}

repositories {
  jcenter()
}

From maven central

Add maven central to your build.gradle:

buildscript {
  repositories {
    mavenCentral()
  }
}

repositories {
  mavenCentral()
}

Then declare MultiSpinner within your dependencies:

dependencies {
  ...
  compile('com.thomashaertel:multispinner:0.1.0@aar') {
  }
  ...
}

Maven

From maven central

To use MultiSpinner within your maven build simply add

<dependency>
  <artifactId>multispinner</artifactId>
  <version>${multispinner.version}</version>
  <groupId>com.thomashaertel</groupId>
</dependency>

to your pom.xml

If you also want the sources or javadoc add the respective classifier

  <classifier>sources</classifier>

or

  <classifier>javadoc</classifier>

to the dependency.

License

multispinner's People

Contributors

thomashaertel avatar akiller avatar

Watchers

James Cloos 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.