// first way to do it
List<String> worldList; // as global variable
// in doInBackground(String... args) {} function instead of this line productsList.add(map);
// use this one :
protected String doInBackground(String... args) {
// your code ....
worldList = new ArrayList<String>(map.values()); // return List object
}
// in onPostExecute(String file_url) function
// then use it in your ArrayAdapter now you are happy
protected void onPostExecute(String file_url) {
// your code ...
mySpinner.setAdapter(new ArrayAdapter<String>(MainActivity.this,
android.R.layout.simple_spinner_dropdown_item,
worldlist));
}
//Value of worldList could be String or Integer what ever you want
//done
// second way to do it
// however you can convert HashMap to array like so
String[] worldArray; // as global variable
// in doInBackground(String... args) {} function instead of this line productsList.add(map);
// use this one :
protected String doInBackground(String... args) {
// your code ....
worldArray = map.values().toArray(new String[map.size()]); // return array
}
// in onPostExecute(String file_url) function
// then use it in your ArrayAdapter now you are happy
protected void onPostExecute(String file_url) {
// your code ...
mySpinner.setAdapter(new ArrayAdapter<String>(MainActivity.this,
android.R.layout.simple_spinner_dropdown_item,
worldArray ));
}
//done
i show you tow ways to do it coz ArrayAdapter constructor could take array or list,
i hope that's helpfull.