I have ArrayAdapter for spinnner and i want to add item to this spinner. My code like below
public void parser()
{
final ArrayList<HashMap<String, String>> valuesList = new ArrayList<HashMap<String,String>>();
for(int i = 0;i<response.getPropertyCount();i++){
SoapObject dersListesi = (SoapObject)response.getProperty(i);
for (int j = 0; j < dersListesi.getPropertyCount(); j++) {
Object objectNames = dersListesi.getProperty(j);
SoapObject ders_kodu = (SoapObject)objectNames;
SoapObject ders_adi = (SoapObject)objectNames;
HashMap<String, String> map = new HashMap<String, String>();
String dersKodu = ders_kodu.getProperty("dersKodu").toString();
String dersAdi = ders_adi.getProperty("dersAdi").toString();
map.put( dersKodu,dersAdi);
valuesList.add(map);
System.out.println( "map"+map);
System.out.println(dersAdi);
}
ArrayAdapter<HashMap<String, String>> ad =
new ArrayAdapter<HashMap<String,String>>(this,
android.R.layout.simple_list_item_1,valuesList);
ad.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinnerDersKodu = (Spinner)findViewById(R.id.derscombo);
spinnerDersKodu.setAdapter(ad);
}
}
This code work correctly but my spinner's output like this:
{BIM101=Computer Programming}
How I can remove these curly braces and = ?
Thanks for help.
Change the your ArrayAdapter to hold string instance. You do not need an ArrayList of HashMap, if the purpose it's just printing the key and the value of the HashMap
final ArrayList<String> valuesList = new ArrayList<String>();
for(int i = 0;i<response.getPropertyCount();i++){
SoapObject dersListesi = (SoapObject)response.getProperty(i);
for (int j = 0; j < dersListesi.getPropertyCount(); j++) {
Object objectNames = dersListesi.getProperty(j);
SoapObject ders_kodu = (SoapObject)objectNames;
SoapObject ders_adi = (SoapObject)objectNames;
String dersKodu = ders_kodu.getProperty("dersKodu").toString();
String dersAdi = ders_adi.getProperty("dersAdi").toString();
valuesList.add(dersKodu+ " " + dersAdi);
}
ArrayAdapter<String> ad =
new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1,valuesList);