如何通过Android的布局XML将数组作为标签的任何视图 [英] How to Set an array as Tag to any View through layout xml in android

查看:140
本文介绍了如何通过Android的布局XML将数组作为标签的任何视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要绑定一些额外的数据,以期。我正在使用我的XML文件中的标记,添加额外的信息。

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

如果数据是唯一的字符串(机器人:标签=额外信息),我能够通过使用 getTag来获得额外的数据()在code。

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

但我想多个数据对象绑定到一个视图,为我设置一个数组变量。 当我试图设置机器人:标签=@阵列/ xyz_array,我仍然得到一个String对象,而不是一个数组从 getTag()

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 ??

推荐答案

您无法从XML做到这一点,XML支持的观点仅标签的字符串。

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

这篇关于如何通过Android的布局XML将数组作为标签的任何视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆