这是activity。xml显示了一个错误
No resource found that matches the given name (at 'text' with value '@string/hello_world').
我的activity.xml中没有@string/hello_world
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal" >
<Button
android:id="@+id/press_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/press_button"
/>
</LinearLayout>
</LinearLayout>
这是我的strings。xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">GpsLocater</string>
<string name="action_settings">Settings</string>
<string name="press_button">Press Button</string>
</resources>
当你创建一个活动时它会自动把hello world放在字符串和活动中但是我去掉了它所以这次的错误是什么?
删除项目中gen目录下的R.java。它应该重新创建R.java。那应该没问题了。
清空项目,重新启动IDE