• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps listview onclick question

creatiive

Lurker
hey,

I have populated my list using a SimpleCursorAdapter with info from my sqlite database;

Code:
SimpleCursorAdapter sca = new SimpleCursorAdapter(this, R.layout.row, c, from, to);
setListAdapter(sca);

This successfully populates my views in the row.xml with the fields i get from the database! Now, my question is probably ridiculously easy, but im having trouble with actually getting the item-specific info when the list item is clicked in my onListItemClick method;



Code:
public void onListItemClick(ListView parent, View v, int position, long id) { 
Intent intent = new Intent(this,Log.class);
intent.putExtra("itemID",0);
startActivity(intent);[/LEFT]
}
[LEFT]

Essentially, where the '0' is, instead i want to get a value from the listitem that was clicked - which is actually being displayed in the view already!

any pointers would be great!!

 
You have probably already found the answer but
change
Code:
intent.putExtra("itemID",0);
to
Code:
intent.putExtra("itemID", String.valueOf(position+1));
so item 1 will give 1, remove +1 and item 1 will give 0
That should work.:)
 
Back
Top Bottom