1
I’m not sure what’s going on, when I long click on a list item, it sometimes works normally (open a screen where it shows the user the registered information, allowing them to change it), sometimes the app stops and closes and sometimes the app stops and opens a registration page setting the values in the respective fields.
Code that opens the details screen of the registered item:
cDAO.abrirBanco();
contatoArray = cDAO.consultar();
lvContatos.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
@Override
public boolean onItemLongClick(AdapterView<?> adapterView, View view, int i, long l) {
Contato c = contatoArray.get(i);
Intent it = new Intent(MainActivity.this, TelaDetalhe.class);
it.putExtra("contato", c);
startActivity(it);
return true;
}
});
I pick up the sent object like this:
final Contato c = (Contato) getIntent().getSerializableExtra("contato");
If I need to put more parts of the code
what you need most?
– Costamilam
The part where the Adapter is built. To find out if it is the contactArray that is passed to the Adapter and, if so, if it is "read" ever again after it has been passed.
– ramaral
I don’t know if this is what you want to know, but the contactArray contains an arraylist that comes directly from the DAO class search query does not go through the listview Adapter
– Costamilam
If you do not pass, then you cannot use it to get the "Contact" corresponding to the Listview item clicked. Unless the two are somehow "synchronized".
– ramaral
Not what I did but the problem was solved, thanks anyway
– Costamilam