Search code examples
androidlistviewuniqueidentifiersimplecursoradapterandroid-cursoradapter

How to set unique id for views (like button) on listview that made by simple cursor adapter in android java?


I create a dynamic custom listview that contain some elements like button ImageView and etc using custom adapter cursor adapter. this is problem when i click on any button because of duplicate id i lost my specific button. i have set tag for each button and is correct but i can't find my button id. Also i use "button.setID()" but is not worked in some elemnts. How can I set unique id for views (like button) in this case? (In the general view I want work with any element in my listview separately )


Solution

  • You don't need different button(any view) ids... Just access the item with Position and find the view with ID.

    Kindly read and understand the docs before apply..