Hi I am an amateur in android .I would like to add images to my spinner's item. Unfortunately, I dont know how to do it . Below is my xml file and MainActivity. Thanks for reading.
XML FILE
<resources>
<string-array name="walutyarrajwoskie">
<item>ALL</item>
<item>AMD</item>
<item>AZN</item>
<item>BYR</item>
<item>BAM</item>
<item>BGN</item>
</string-array>
</resources>
MAINACTIVITY
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
editText_waluty= (EditText) findViewById(R.id.editText_waluty);
spinner_from =(Spinner) findViewById(R.id.spinner_from);
spinner_to =(Spinner) findViewById(R.id.spinner2_to);
textview_to= (TextView) findViewById(R.id.textView2_to);
button_konwertuj= (Button) findViewById(R.id.button_konwertuj);
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this,
R.array.**walutyarrajwoskie**, android.R.layout.simple_spinner_item);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner_from.setAdapter(adapter);
spinner_to.setAdapter(adapter);
Use custom Spinner
activity_main
custom_spinner_items.xml
MainActivity.java
CustomAdapter.java
Source from this website