0
I got the following ListView
that was generated with a Customized Adapter:
I would like to know how to find the values (date, time, history, id, etc) of the item with the setOnItemLongClickListener
, because I need these values (or at least the value of id
item) to search in SQLite
and open in another screen for editing.
So far tested as follows, but only brings me the position of the item on the list:
this.ltvRegistros.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
@Override
public boolean onItemLongClick(final AdapterView<?> parent, final View view, final int position, long id) {
AlertDialog.Builder dialog = new AlertDialog.Builder(Main.this);
dialog.setTitle("Editar");
dialog.setMessage("Deseja editar o item ?");
dialog.setPositiveButton("Sim", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
CRegistros item = (CRegistros) ltvRegistros.getAdapter().getItem(position);
Toast.makeText(Main.this, "Registro " + item.get_Id().toString() + " apagado !", Toast.LENGTH_SHORT).show();
DBController ct = new DBController(getBaseContext());
ct.buscaRegistro(id);
}
});
dialog.setNegativeButton("Não", null);
dialog.show();
return true;
}
});