im to populate spinner using arraylist , and that arraylist actully holds data from the file having android application data stored already for t=my application, im pasting the
private void setSpinner() {
spinner = (Spinner) findViewById(R.id.spinner_size);
Intent intent = getIntent();
ArrayList sizes = null;
if (intent != null) {
// Receiving ArrayList in Another Activity where "sizeList" is the Key
sizes = intent.getStringArrayListExtra("SizeList");
}
if (sizes != null) {
ArrayAdapter adapter = new ArrayAdapter(this, android.R.layout.simple_spinner_dropdown_item, sizes);
spinner.setAdapter(adapter);
// Spinner click listener
spinner.setOnItemSelectedListener(this);
}
}
Call setSpinner() method from OnCreate() Method. You can directly pass ArrayList as a parameter, you don't need to convert into String[].