Android的资源转换为字符串的TypedValue警告 [英] Android Resources converting to string TypedValue warning

查看:1307
本文介绍了Android的资源转换为字符串的TypedValue警告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好吧,我正在寻找正确的过去的东西在这里。

Ok I'm looking right past something here..

每当我在我的应用程序,我改活动,logcat的报告一系列警告:

Every time I'm in my app and I change activities, logcat reports series of warnings:

02-04 14:42:36.524: WARN/Resources(1832): Converting to string: TypedValue{t=0x12/d=0x0 a=2 r=0x7f08002b}
02-04 14:42:36.524: WARN/Resources(1832): Converting to string: TypedValue{t=0x12/d=0x0 a=2 r=0x7f08002c}
02-04 14:42:36.524: WARN/Resources(1832): Converting to string: TypedValue{t=0x12/d=0x0 a=2 r=0x7f08002d}

其他应用程序都没有表现出这样的警告。这是一个pre释放/ AAPT COM pression事?

Other apps are not showing such warnings. Is this a pre-release/aapt compression thing?

推荐答案

您正在使用,其中一个字符串预计布尔的资源。

You are using a bool resource where a string is expected.

您可以找到它的资源正在使用错误地打开你的生成R.java文件,搜索从logcat的消息的资源ID:

You can find which resource is being used incorrectly by opening your generated R.java file and searching for the resource IDs from the logcat message:

0x7f08002b
0x7f08002c
0x7f08002d

这三个应该是从你的bool.xml文件(在警告信息的T = 0×12是指资源<一href="http://developer.android.com/reference/android/util/TypedValue.html#TYPE_INT_BOOLEAN">TYPE_INT_BOOLEAN).

然后,找到那里的资源ID被在项目中使用(可能是一个布局的XML,但可以在任何地方),并确保类型匹配。

Then, find where those resource IDs are being used in your project (probably a layout xml, but could be anywhere) and make sure the types match.

下面是一个TextView,将生成日志消息的一个例子。如果我的RES /价值/ bool.xml我有:

Here's an example of a TextView that would generate that log message. If in my res/values/bool.xml I have:

<resources>
    <bool name="foo_flag">false</bool>
</resources>

我可能会错误地引用它由AA布局xml文件:

I can incorrectly refer to it from a a layout xml file:

<TextView android:id="@+id/foo"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="@bool/foo_flag"></TextView>

当我运行的应用程序,我会得到警告信息,因为文本预计字符串资源,而不是一个布尔(如预期,但因为该标志被转换成字符串false我的应用程序出现)。

When I run that app, I'll get the warning message since "text" expects a string resource, not a bool (my app appears as expected though since the flag is converted to the string "false").

这篇关于Android的资源转换为字符串的TypedValue警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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