密钥必须是应用程序特定的资源ID [英] The key must be an application-specific resource id
本文介绍了密钥必须是应用程序特定的资源ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
为什么我得到这个例外?
05-18 20:29:38.044:ERROR / AndroidRuntime(5453):java.lang.IllegalArgumentException:如果该键必须是一个应用程序特定的资源ID。
05-18 20:29:38.044:ERROR / AndroidRuntime(5453):在android.view.View.setTag(View.java:7704)
05-18 20:29:38.044:ERROR / AndroidRuntime(5453):在com.mypkg.viewP.inflateRow(viewP.java:518)
在这行是:
((按钮)row.findViewById(R.id.btnPickContact))setTag(TAG_ONLINE_ID,objContact.onlineid)。
和我把它定义为:
私有静态最终诠释TAG_ONLINE_ID = 1;
解决方案
标签的ID必须是唯一的,因此希望它是一个资源文件中创建保证唯一性的ID。
如果该视图将只包含一个标签,虽然你可以做
setTag(objContact.onlineid);
Why do I get this Exception?
05-18 20:29:38.044: ERROR/AndroidRuntime(5453): java.lang.IllegalArgumentException: The key must be an application-specific resource id.
05-18 20:29:38.044: ERROR/AndroidRuntime(5453): at android.view.View.setTag(View.java:7704)
05-18 20:29:38.044: ERROR/AndroidRuntime(5453): at com.mypkg.viewP.inflateRow(viewP.java:518)
the line in question is:
((Button) row.findViewById(R.id.btnPickContact)).setTag(TAG_ONLINE_ID,objContact.onlineid);
and I have it defined as:
private static final int TAG_ONLINE_ID = 1;
解决方案
The tag id must be unique so it wants it to be an id created in a resources file to guarantee uniqueness.
If the view will only contain one tag though you can just do
setTag(objContact.onlineid);
这篇关于密钥必须是应用程序特定的资源ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文