Search code examples
javaandroidandroid-listviewsimpleadapter

How to get ListView position and corresponding SimpleAdapter data of the row where checkbox was clicked?


I have a ListView which shows users names.The ListView get this data from the SimpleAdapter.Each row in this ListView has a TextView which shows users names and a ComboBox which is used for selecting corresponding name.The problem I don't know how to get row position and corresponding SimpleAdapter data of the currently checked CheckBox.How can I achieve this?


Solution

  • If I understand your question correctly, you want to find the index of the view which contains a checked checkbox.

    Try this to get the index:

    int index = listView.indexOfChild(checkBox.getParent());
    

    Once you have the index, you can do this to get the data:

    View customView = listView.getChildAt(index);