5

I want to bind some extra data with a view. I am using tag in my xml file to add the extra information.

If the data is only String (android:tag="extra Info"), i am able to get the extra data by using getTag() in code.

But i want to bind multiple data as object to a view, for that i am setting an array as tag. When i tried to set android:tag="@array/xyz_array", I am still getting a String object instead of an array from getTag().

Can any body tell me, if i am doing something wrong ??

2 Answers 2

10

You can't do this from XML, XML supports only strings for view tags.

Sign up to request clarification or add additional context in comments.

1 Comment

@Romain Guy: can you elaborate for better understanding of other readers. Do you mean we can do it via code using setTag() but not via putting some class attribute in xml directly ?
4

Actually you can do that if you define tag elements as a child for views. Define multiple Tag attribute for View in xml layouts

<View ...>
     <tag android:id="@+id/mytag"
          android:value="@string/mytag_value" />
 </View>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.