Reputation: 4464
is it possible for a Spinner
to return multiple values or class object on selected?
For example I have a Spinner of Laptop models. When selected I want it to return LaptopSpecs
object that contains size, weight, processor, etc. Then use it to display the information in the view below it.
Thanks
Upvotes: 0
Views: 1238
Reputation: 16393
It depends on how you are populating your spinner.
If you are pulling the data from a database in a cursor, what you are trying to do is easy.
As a matter of fact, using a database, there's a couple ways you can do it:
1) You simply pull all the necessary data you need to create the object into your cursor (kinda heavy load on the front end), and when a selection is made (fromthe single bit of data displayed in the spinner), you use the cursor position reference in the onItemSlected
method to pull the related data from the cursor and pack it into your object.
2) You pull only the piece of data to display in the spinner and when a selection is made, use the database row id in the onItemSelected
method to fetch the rest of the data for your object from the database.
Upvotes: 1
Reputation: 1007340
Sorry, there is no multi-select Spinner
. You are welcome to use a multi-select list AlertDialog
to allow the user to make their selection(s), but you will need to decide for yourself how you want to render those selection(s) when the dialog is not on the screen.
Upvotes: 2