Giter VIP home page Giter VIP logo

dropdownlist's Introduction

Drop-down list is a common UI feature used when we have to select one or more values from a list.
Android SDK provides Spinner widget for implementing drop-down list. But Spinner is limited to single value selection.
So, if we need multi-select drop-down list, it can be done using Pop-up window and multi-select ListView.

DropDownList is a simple implementation of Multi-select drop-down list.
Here, I have used:
1) A TextView : To display selected values and also which acts as anchor view for drop down
2) A Button : To display/hide the drop-down list
3) A Pop-up Window : This is used to represent the drop-down list
4) A ListView : To display the list of values

How this is done? 

1) First the TextView and Button are set up 
2) When the button is clicked, the drop-down list (pop-up window) is displayed:
   The properties of pop-up window are set such that it will be informed of the touch events outside its window.
          
          pw.setBackgroundDrawable(new BitmapDrawable());   
          pw.setOutsideTouchable(true);
  
   TextView is given as anchor view for this pop-up window.
   The ListView is populated with the data source provided.
3) Whenever a value is selected in the list, the TextView is updated with new selected values.
   This is done by maintaining select/unselect information about each value in form of boolean[] 'checkSelecte[]'
4) The TextView displays the selected values in two representations:
    i) Shortened representation: e.g. 'Item 1 & 2 more'
    ii) Complete list of selected values
    These representations can be alternatively when the TextView is clicked

And we are done with Multi-Select Drop-down list !

dropdownlist's People

Contributors

asnehal avatar

Watchers

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