I'm writing a poll application.
I have a main_view.xml and poll_item_view.xml. main_view.xml is just the container for all the poll results and poll_item_view is one particular poll result. I'm inflating the poll_item_view.xml multiple times inside the main-view to show a list of poll results.
Now periodically I need refresh the poll results, as and when people vote. I need a way to refer to each of the poll_item I inflated inside the main_view. Is there a wasy to set a unique id to each poll item which I can later use to get a reference to a particual poll item.
Thanks, Aryan
You could use View.setTag
and View.getTag
.
If you use onClickListener of your view you have a ref. to this view. If you update items outside, you can use indexes and getChildAt method.
Also good method to create wrappers of view with ref. to fields for quick access and update