找不到与main.xml中给定名称匹配的资源

时间:2010-05-22 18:14:03

标签: android

这真的让我发疯了。

<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
  android:id="@id+/textview"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  android:text="@string/hello"/> 

产生以下错误消息:“Error: no resource found that matches the given name (at 'id' with value '@id+/textview')

这是从Android hello世界复制并粘贴的 example

2 个答案:

答案 0 :(得分:25)

@+id不是@id+。似乎教程是错误的!

答案 1 :(得分:8)

这只是一个小错字;你需要把'+'放在'@'之后,而不是'id'之后:

<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
  android:id="@+id/textview"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  android:text="@string/hello"/> 
相关问题