kavie
kavie

Reputation: 2244

Parameters in onItemClick

I'm reading about the Use of OnItemClick Paramter in this link https://developer.android.com/reference/android/widget/AdapterView.OnItemClickListener.html

Can any one explain me the exact difference between 3rd & 4th Parameters(position & id)

position int: The position of the view in the adapter.

id long: The row id of the item that was clicked.

Upvotes: 0

Views: 687

Answers (2)

Code-Apprentice
Code-Apprentice

Reputation: 83557

Often position and id are the same, but they do not have to be. Position is the index in the underlying dataset, whether it is an array, ArrayList, or Cursor. id is a unique identifier for the object displayed in the child view. For example, this can be the primary key for a row in a database table.

Upvotes: 1

dgngulcan
dgngulcan

Reputation: 3149

Position is the position index of the item in the adapter id is the id of the item in that position that is returned from getItemId() which is row index by default.

Upvotes: 0

Related Questions