I have two Spinners. One of them is populated on run-time.
groupSpinner.setAdapter(new ArrayAdapter<>(this,
android.R.layout.simple_spinner_item, groupNames));
The other one is pre-populated in the XML layout using a String array.
<Spinner ...
android:entries="@array/my_items_here" />
Both Spinners appear fine. However, when their items are shown, the children layouts do not match, both in dropdown
and in dialog
mode.
I must be missing something very simple, but how can I set them to use the same layout (hopefully android.R.layout.simple_spinner_item
), without creating my own custom layout, or loading the XML String array on run-time?
It seems a basic thing to do, but I cannot find an answer and I have searched a lot, already.
See screenshots, below:
*Please forgive the use of Greek characters in the second image. I have checked and confirmed that the problem is not related to the use of Greek characters.
android.R.layout.simple_spinner_dropdown_item
instead ofandroid.R.layout.simple_spinner_item
– HochheimerSpinner
item of the firstSpinner
, look different from the other, within theSpinner
itself. The question is, how to change the item layout for the XML pre-filled one? It doesn't seem to offer a way to manipulate that, unless you manually create theSpinner
adapter. – Gravittadapter.setDropDownViewResource()
? Also, are both under the same theme/style? – Culberson((ArrayAdapter)preFilledSpinner.getAdapter()).setDropDownViewResource(android.R.layout.simple_spinner_item);
– HochheimergetAdapter
of theSpinner
was the part that actually solved it for me. Moreover, Moinkhan had been around for an hour. – Gravitt