I am working with a form to edit the information of a client, the form has three AutoCompleteTextView
.
Each AutoCompleteTextView
has an adapter that receives a List<Object>
. As it is a form to edit, you need each AutoCompleteTextView
to start with the Object
that is saved in the database.
final AutoCompleteTextView acContactos = (AutoCompleteTextView) dialog.findViewById(R.id.acContactos);
final List<Contacto> contactos = new ContactoSQL(getContext()).getContactos();
final ArrayAdapter contactosAdapter = new ArrayAdapter<Contacto>(getContext(), android.R.layout.simple_dropdown_item_1line, contactos);
acContactos.setAdapter(contactosAdapter);
acContactos.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
contacto = (Contacto) contactosAdapter.getItem(position);
}
});
For example, the selected client has the contact with id 8, which in List<Object>
has index 7 and that Contacto
should be selected by default when opening the form to edit the Client.
I remain attentive to your comments and help, greetings.