I know that the base different is that setId()
takes int
as a parameter, while setTag()
takes Object
. I am asking more about practical advice.
When I generate more same elements programmatically, I set their IDs via setId(++counter)
and that is fine for me to know which element has sent the onClick
event. And I could do the same thing via setTag(++counter)
, but I am used to the previous approach.
So when should I use setTag()
and am I making a mistake when using setId()
?
I guess if my way is right, then I'd use setTag()
when I want to pass additional data, but I'll leave you comment on this issue first.