你引用一个字符串你好在的strings.xml这是不存在的strings.xml文件世界国际。
您不能以编程方式更改strings.xml中的值。
您可以执行以下操作以编程方式更改textview中的文本。
TextView tv= (TextView) findViewById(R.id.TextView02);
tv.setText("hello");
or
tv.setText(getResources().getString(R.string.my_string));// refer to the string in strings.xml programatically.
可以在XML
<TextView
android:id="@+id/TextView02"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="hello"
android:textSize="20dip" >
设置文本的strings.xml
<string name="my_String">Hello World</string>
在XML文件中,您可以参考上面的字符串
<TextView
android:id="@+id/TextView02"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/my_string"
android:textSize="20dip" >
http://developer.android.com/guide/topics/resources/string-resource.html。看看链接。
以上链接为例。保存在RES /价值/ strings.xml中
XML文件:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="hello">Hello!</string>// hello is defined here in strings.xml
</resources>
这种布局XML应用将一个字符串查看:
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello" />// resource hello is refered here.
你确定你要打开同一个项目的string.xml档案? – Raynold 2013-03-15 08:30:38
请说明你得到了什么样的错误,以及你如何将未知变成你好世界?我认为这是你混合起来的地方。 – 2013-03-15 08:32:43
我不明白你的意思是“我改变我的价值android:在main.xml中的文本” – njzk2 2013-03-15 08:41:05