I face this difficulty. In my case when i click on textview which is part of list-view’s custom XML file then the position is right, but when i click on the button which is the part of list-view’s custom XML file then it always gives first position.
After i have to decided to perform automatic onItemClick and store all the values of clicked position into another declared variable which is below. See the image i used kotlin language instead of java. I stored all the map values into another variable which is declared above with public access specifier.
[Now when i perform operation on Button click i use
lvShayari.performItemClick(v, lvShayari.getPositionForView(v), lvShayari.selectedItemId)
this statement in which lvShayari is listview and performItemClick() method perform the onItemClick automatically when we clicked on button. Here v is the view, lvShayari.getPositionForView(v) method gives the position of v in my case it is button.