Answer the question
In order to leave comments, you need to log in
How to get _id on click in ListView?
/layout/item.xml has two TextViews with title and description (R.id.tvText and R.id.tvTextDesc). I fill ListView from sqlite.
to data array from sqlite
String[] from = { LINE_TITLE, LINE_DESC };<br/>
int[] to = { R.id.tvText, R.id.tvTextDesc };<br/>
SimpleAdapter sAdapter = new SimpleAdapter(this, data, R.layout.item, from, to);<br/>
lvSimple = (ListView) findViewById(R.id.lvSimple);<br/>
lvSimple.setAdapter(sAdapter);<br/>
lvSimple.setOnItemClickListener(new OnItemClickListener() {<br/>
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {<br/>
}
Answer the question
In order to leave comments, you need to log in
You can store the _id via setTag on the View, in the adapter's getView method.
on the SelectedIndexChanged event, you can do it, for example.
The article describes how to do it, and with examples
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question