Multiple selection in Spinner android - android

I am using a Spinner and ArrayAdapter to populate items in Spinner. I want to make the spinner multi-selectable i.e. user can select multiple items and should also be able to deselect to none. My code is as below,
spnAdapter = new ArrayAdapter<String>(this,android.R.layout.select_dialog_multichoice,items);
spnAdapter.setDropDownViewResource(android.R.layout.simple_list_item_multiple_choice);
spnProducts.setAdapter(spnAdapter);
Here the items is an array list.
This code gives me a spinner with check boxes but it does not allow multiple selection. What should I do to make it multiple selection?
Thanks in advance.

Related

how to select the multiple values in a spinner by checking the checkbox. And i need to fetch the selected item from the spinner?

I want to select multiple values in a spinner by checking the checkbox and I need to fetch the selected items from the spinner.
Try this way here is prefect example
https://asnehal.wordpress.com/2012/04/03/

Custom List View multiple item selecting

Am new to development and have doubt in selecting listview items using android.
I have an listview with list of data from mysql and also have checkbox for selecting items and have button to pass the selected items to next screen.
What i want to know is how to select multiple items and send to next activity using the button.
Awaiting for your kind reply.
Perfect tutorial for your problem, might it will help you
ANDROID: MULTIPLE SELECTION LISTVIEW

Android spinners populate with data

I have three spinners in my activity. based on the item selected in first spinner the second spinner is populated with a new set of values. till here the program works fine. now i want that based on selection of item on 2nd spinner the third spinner should be populated. but i am not able to achieve this.
As you can do on the first spinner and second spinner. use secondSpinner.setOnItemSelectedListener(new OnItemSelectedListener() and then create and setAdapter to the third spinner.
see this question might help

How to get seleceted items from a listView

I'm trying to find a way to add a checkBox to a ListView layout that can be used to allow the user to select items to be processed. The listview is populated using a cursor via a SimpleCursorAdapter. Can anyone point in the direction on documentation describing how to do such a thing.
You need to manage the selected items in the listview in the getView method manually. At last you will get the selected items. use Arraylist or hashmap as per your need and comfort.
Hope it will help you.
Also refer these links:
Android ListView with Checkboxes: How to capture checked items?
Android ListView
Adding CheckBoxes to a Custom ListView in Android
how to display all checked items from multiple choice listview

Sorting items in a listview alphabetcally,price rating

my apllication has a listview that contains:
1.Title
2.Image
3.Rating
4.Price
Now i want to implement sorting in my listview ie through a dropdown box or spinner so that i can sort the items alphabetically,rating etc
Please provide me with some code.....
You will have to check for the options selected into the spinner and based on that,you will have to send your sorted data to the listview(if you are using CursorAdapter,then everytime cursor should be fetch in sorting order you want your items to be in) for each of your option.
reloading the listview is the only solution to your problem,AFAIK.

Categories

Resources