views:

25

answers:

0

I need to create a dialog with a list containing an autocomplete text view and a button for each line. So everything is working except for the autocomplete text view. My program crashes when i tried to call the setAdapter. that's my code:

 private Dialog createSosteDialog() {
 final ArrayList<HashMap<String, String>> mylist = new ArrayList<HashMap<String, String>>();
 Button conferma_modifiche_soste;

 ListView lv;
 final Dialog sosteDialog = new Dialog(this);
 sosteDialog.setTitle("Lista soste");

 sosteDialog.setContentView(R.layout.modifica_soste_dialog_layout);

 lv=(ListView)sosteDialog.findViewById(R.id.lista_write);
 conferma_modifiche_soste=(Button)sosteDialog.findViewById(R.id.Conferma_modifiche_soste);
 AutoCompleteTextView autocomplete=(AutoCompleteTextView)sosteDialog.findViewById(R.id.autocomplete_soste);

 String[] fermate_dispositivo = getResources().getStringArray(R.array.Lista_fermate_dispositivo);
 ArrayAdapter<String> adapter_autocomplete = new ArrayAdapter<String>(this, R.layout.auto_complete_item, fermate_dispositivo);
 autocomplete.setAdapter(adapter_autocomplete); //ERROR WITH THIS LINE!!!!

           HashMap<String, String> map;// = new HashMap<String, String>();

 int i;
 for(i=0;i<soste.length;i++){
 map = new HashMap<String, String>();
 map.put("sosta", soste[i].getNome());
 map.put("orario", soste[i].getStringOrario());
 mylist.add(map);
}

    SimpleAdapter adapter = new SimpleAdapter(this, mylist, R.layout.lista_soste_item_modifica,
                new String[] {"sosta", "orario"}, 
                new int[] {R.id.autocomplete_soste, R.id.lista_soste_cambia_orario});
    //new String[] {"from", "to"} imposta le colonne "sosta" e "orario" della map come valori    

    lv.setAdapter(adapter);
return sosteDialog;
}