---
title: "AndroidTextView在xml初始化的问题"
author: "test_angel"
date: "2016-07-19T09:59:53Z"
tags: []
categories: ["移动开发"]
slug: "androidtextview-xml"
draft: false
lastmod: "2016-07-19T10:02:08Z"
id: 2312101
url: "https://test-angel.iteye.com/blog/2312101"
---

packages/apps/TabPro/res/layout/tab1.xml:7: error: Error: This attribute must be localized. (at 'text' with value '0%').  
packages/apps/TabPro/res/layout/tab2.xml:7: error: Error: This attribute must be localized. (at 'text' with value '0%').  
packages/apps/TabPro/res/layout/tab3.xml:7: error: Error: This attribute must be localized. (at 'text' with value '0%').  
make: \*\** \[out/target/common/obj/APPS/TabPro\_intermediates/src/R.stamp] 错误 1

提示了错误“This attribute must be localized”，这种问题一般情况是因为在res/xml文件夹下的中  
或者在res/layout下的文件中出现了没有多语言话的文本例如  
&lt;TextView  
android:id="@+id/myTextView1"  
android:text="0%"  
android:layout\_width="fill\_parent"&gt;  
&lt;/TextView&gt;  
解决方式  
在res/values/strings.xml中定义字符串  
&lt;string name="str\_tab1"&gt;0%&lt;/string&gt;

然后把上面的内容改为  
&lt;TextView  
android:id="@+id/myTextView1"  
android:text="@string/str\_tab1"  
android:layout\_width="fill\_parent"&gt;  
&lt;/TextView&gt;  
这是android强制实行多语言话

 

所以说初始化一定要在string中，即使是一个小小的0