For now I want a Toast that just shows the number that is being passed into ID. (Primary keys for each row).
If you want the primary key from your database, (depending on the adapter) it should be the id
parameter passed to onItemClick()
:
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
// Use id
Toast.makeText(Contacts.this, id + "",Toast.LENGTH_SHORT).show();
// Or you can find it yourself
TextView idTV = (TextView) view.findViewById(R.id.id);
Toast.makeText(Contacts.this, idTV.getText().toString(),Toast.LENGTH_SHORT).show();
}
Addition
Now that you posted your adapter I see that you can adjust your getItemId()
method to return data from your ArrayList<String> id
to make the id
parameter in onItemClick()
work:
public long getItemId(int position) {
return Long.parseLong(id.get(position));
}
(You can even change the container type from ArrayList<String>
to ArrayList<Long>
if it makes sense in your context.)