0

I need to map certain type identifiers to my Spinner's adapter.

I have defined the type identifiers as constants:

public static int TYPE_SOMETYPE = 0;
// etc..

Now, how could I find out what type was selected in the spinner? What sort of SpinnerAdapter is the right tool for the job?

Gerstmann
  • 5,368
  • 6
  • 37
  • 57

2 Answers2

2

You could implement you own adapter class, using the BaseAdapter interface. It implements the SpinnerAdapter interface, so you can use it as an adapter for a Spinner.

In this adapter, you should store the items you need to present, and e.g. set you custom IDs as tags for every row View returned in .getView() with .setTag(). Or, you can return those IDs in the .getItemId() method, based on the items position.

Zsombor Erdődy-Nagy
  • 16,864
  • 16
  • 76
  • 101
1

I think you'd have to hold that extra detail in a hash map or something external to the adapter, and then use the spinner 'position' to get you the type you need?

iaindownie
  • 1,046
  • 12
  • 28