2013-09-29 7 views
8

Nella mia prima attività Ho il codice seguente:Get ArrayList <HashMap <String, String >> valori

ArrayList<HashMap<String, String>> list_params = new ArrayList<HashMap<String, String>>(); 
      HashMap<String, String> param_aux = new HashMap<String, String>(); 

      param_aux.put("language", Integer.toString(language_spinner.getSelectedItemPosition())); 
      param_aux.put("city", city_edittext.getText().toString()); 

list_params.add(param_aux); 

E nella mia seconda attività voglio ottenere i valori, quindi il mio codice è:

ArrayList<HashMap<String, String>> list_params_ = new ArrayList<HashMap<String, String>>(); 
    list_params_= (ArrayList<HashMap<String, String>>) getIntent().getSerializableExtra("list_params"); 

    System.out.println("...serialized data.."+list_params_); 

Se check System.out, i valori sono corretti, ma voglio ottenere un valore specifico di HashMap (esempio: valore della città).

...serialized data..[{weekend_midday_check=1, weekend_afternoon_check=0, weekend_morning_check=1, sort_by=0, language=0, weekly_afternoon_check=1, weekly_morning_check=1, weekly_midday_check=1, city=Terrassa}] 

Come posso ottenere il valore per la città inviato nella prima attività?

risposta

22

Usa:

list_params_.get(0).get("city"); 
+0

Grazie, che funziona perfettamente !! – MarcForn

+0

Nessun problema, accetta la risposta se ti ha aiutato :) –