2015-08-24 161 views
-3

这是一个应用程序的一些代码,将打印你好世界到我的手机。但是,当我尝试在Android Studio中将文本从“@ string/hello_world”更改为其他内容(例如“@ string/hello”)时,它会引发错误。谁能帮忙?Android代码投掷错误

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" 
android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin" 
android:paddingRight="@dimen/activity_horizontal_margin" 
android:paddingTop="@dimen/activity_vertical_margin" 
android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity"> 

<TextView android:text="@string/hello_world" android:layout_width="wrap_content" 
    android:layout_height="wrap_content" /> 

+0

具有u加入'strings.xml'字符串'hello'?在'res - > values - > strings.xml'中打开'strings.xml'。你会发现一行' Hello world!' –

+0

这是什么(这是我第一次使用这个) – Sruli

+0

如果你的意思是在这个 Sruli

回答

0

转到您的res文件夹 - >数值 - > strings.xml中。

在该文件中,您可以找到字符串名称和值。

只需更改名称和值,然后在布局中输入该名称即可。

<string name="Hello_world">Hello World</string> 

<string name="Hello">My First Application</string>