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

And*_*ner 13 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"/> 
Run Code Online (Sandbox Code Playgroud)

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

这是从Android hello world 示例中复制和粘贴的 .

Chr*_*ris 25

@+id没有@id+.好像教程错了!


Dan*_*Lew 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"/> 
Run Code Online (Sandbox Code Playgroud)