Given the code bellow, is it possible to have images instead of text in the array planets?
Spinner s = (Spinner) findViewById(R.id.spinner);
ArrayAdapter adapter = ArrayAdapter.createFromResource(
this, R.array.planets, android.R.layout.simple_spinner_item);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
s.setAdapter(adapter);
and
<string name="planet_prompt">Choose a planet</string>
<string-array name="planets">
<item>Mercury</item>
<item>Venus</item>
<item>Earth</item>
<item>Mars</item>
<item>Jupiter</item>
<item>Saturn</item>
<item>Uranus</item>
<item>Neptune</item>
</string-array>
I just needed a super easy solution for a fixed set of images in a spinner, so I did this:
}
And then in the code you can just use it like this:
Yes it is look at the code below:
creating List of hashmaps
assigning spinner to adapter
the adapter used above is as given below..