Change data from a specific position in the ListView

3

I would like to know how I can change data from a certain ListView position.

Here I load the database from the ListView:

public void carregarEmails(Cliente cliente) {
    ArrayList<Email> listaView = dao.pegarResultListaEmail(cliente);
    listaEmail.setAdapter(new ClienteCadEmailBaseAdapter(getActivity(), listaView));
}

Code that retrieves data from selected line:

private void informacaoSelecionadaEmail(View v) {
    listaEmail = (ListView) v.findViewById(R.id.lstEmails);
    listaEmail.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            Object o = listaEmail.getItemAtPosition(position);
            objEmail = (Email) o;
            posicaoEmail = position;
            edtEmail.setText(objEmail.getEmail());
        }
    });
}

Now to get the changed in EditText and send it to the line again I have no idea how to do it.

    
asked by anonymous 13.10.2015 / 23:19

1 answer

1

The ListView is a visual representation of data coming from a data source . Data is converted to Views using an Adapter

So, to change any data / value shown by the ListView , you need to change this value in the data source and inform the Adapter of that change, using the adapter.notifyDataSetChanged () method.

    
14.10.2015 / 11:28