I want to bind some information by attaching tags to a view. So when the view is clicked I can retrieve this information with its tag. However, I meet problem when using an int array as the tag. I save two integers by following samples:
int arr=[x,y];
view.setTag(arr);
parentView.addView(view);//parentView is a list/LinearLayout of such views
Later, when I want to find the view using
int tmp=[i, j];//i=x, j=y in values
View target=parentView.findViewWithTag(tmp);
The returned target
is null
. Why does it not return the correct view?
Edit:
I'm not sure if it's because of object reference and comparison issue. I tried to combine integers x
and y
into a string like "x,y"
, and search the view like parentView.findViewWithTag("x,y")
and it can find the view.