I have an activity displaying call logs in a ListView. The adapter used here to populate the list extends the CursorAdapter. Listview is set to onItemClickListener (..). My question is, whenever an element is clicked, how does the cursor get the data? how does the cursor know which position is pressed, and you only need to get data from the position just pressed? I have provided snippnet code.
public class CallLog extends Activity { ListView mListView; Cursor cursor; //other variables public void OnCreate() { setContentView(R.layout.calllog); //SQLiteDatabaseInstance db cursor = db.query(...parameters to get all call logs...); mListView.setOnItemClickListener(this); } public void OnItemClick( // all arguments... ) { //there is a column name 'NAME' in call log table in database String name = cursor.getString(cursor.getColumnIndex(Database.NAME)) //here name is obtained of the clicked item. }
A cursor is a result set. how does the cursor know which element to click? What can be methods implicitly called a cursor that gives it the position of the clicked element?
If there are any links with a similar question, then pls provide.
I hope I can make you understand this question. thank you
source share