progNewbie
progNewbie

Reputation: 4832

Android: Identify listviewItem when checkbox of item is checked/unchecked

I got a listView with dynamically created items. Each item has a checkbox which can be checked/unchecked. When the checkbox is pressed this function is called:

public void updateClientList(View v) {
}

Now I want to change the specific item in my arraylist which is the base of the listview. But how do I know which checkbox was checked?

How can I do that? Thanks for your help!

Upvotes: 0

Views: 51

Answers (1)

dzsonni
dzsonni

Reputation: 193

If you only have a checkbox, you can use the OnItemClick listener that gives you position besides the view, but with this solution you have to update the checkbox manually so it doesnt consume the item click.

Another way is to use setTag(position) on the views you supply when binding.

You should consider moving on to RecyclerView.

https://developer.android.com/reference/android/support/v7/widget/RecyclerView.html

Upvotes: 1

Related Questions