I have the following ListView
that was generated with a custom adapter :
Iwouldliketoknowhowtolookupthevalues(date,time,history,id,etc)oftheitemwithsetOnItemLongClickListener
,asIneedthesevalues(oratleasttheid
valueoftheitem)tosearchtheSQLite
andopeninanotherscreenforediting.
SofarI'vetesteditasfollows,butitonlybringsmethepositionoftheiteminthelist:
this.ltvRegistros.setOnItemLongClickListener(newAdapterView.OnItemLongClickListener(){@OverridepublicbooleanonItemLongClick(finalAdapterView<?>parent,finalViewview,finalintposition,longid){AlertDialog.Builderdialog=newAlertDialog.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;
}
});