views:

632

answers:

1

I have a spinner widget in my activity which lets users pick a list name.

Normally, the function of the spinner is to switch between lists but for a couple of instances, I swap out the selection change listener to perform a different function with the same list of options. Once the selection has been made, the old listener is restored and life goes on.

This is a bad and buggy arrangement. Instead, I would like to have a function that just takes a selection listener and some other parameters and shows a popup list that's populated by the same cursor (or and identical cursor) as the spinner, without using the spinner itself.

Is there any way I can do this?

+3  A: 

Use AlertDialog.Builder and supply an Adapter via setAdapter() that generates your rows.

In your case, I would not use the same Cursor, as a Cursor has an intrinsic notion of the current row, and so messing with the Cursor while it is used by your SpinnerAdapter could screw up the Spinner. Go with an identical Cursor.

CommonsWare
I had no idea an AlertDialog.Builder had that functionality. Thanks for the tip. I'll accept your answer if I get it to work out.
CodeFusionMobile