views:

376

answers:

1

I have an android spinner that's populated by a list of strings using an ArrayAdapter and it operates fine, however because of the way the spinner is displayed I'm running into a display height problem with the list items.

At first glance it would seem that the ArrayAdapter can use a single layout for displaying options which leads to the problem I'm having. When displaying the current item in the spinner (when the user is not selecting a new item from the list) the spinner pads the text so that the spinner is a reasonable size for clicking on. However when the user taps on it and brings up the list to select a new item, the list items presented are way to small height-wise. If I use an item layout that presents the list items at a reasonable height, then the spinner itself becomes exorbitantly huge due to it's own padding of the list item.

Any ideas on how I can manage the height of these two item display modes so that effectively they display with the same height value instead of the spinner height being larger than the list item display height?

+2  A: 

I've run into this issue myself a while ago, and it turned out that I need to use different layouts for dropdown and display

I have this code:

adapter = new SimpleCursorAdapter(this, android.R.layout.simple_spinner_item, cGroups,
                new String[] {
                        "name", "_id"
                }, new int[] {
                    android.R.id.text1
                });
        adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
Pentium10
That's perfect. Thank you! Just to be clear the setDropDownViewResource method sets the item view displayed when the user is selecting from a list of items.
rushinge