String types are not allowed (in 'id' with value '@ id / bAdd')

I get an error String types not allowed (in 'id' with value '@ id / bAdd')

  • I cleaned the project.
  • Everything worked before, I did not do this, causing this error.

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout_centerVertical="true" android:text="Your total is 0" android:textSize="45dp" android:layout_gravity="center" android:gravity="center" android:id="@+id/tvDisplay" tools:context=".StartingPoint" /> <Button android:layout_width="250dp" android:layout_height="wrap_content" android:text="Subtract One" android:layout_gravity="center" android:textSize="20dp" android:id=" +@id /bSub" /> <Button android:layout_width="250dp" android:layout_height="wrap_content" android:text="Add One" android:layout_gravity="center" android:textSize="20dp" android:id=" +@id /bAdd" /> 

+7
source share
3 answers

You can specify your identifier as @+id/bAdd

instead of +@id /bAdd

Also edit in

 android:id="@+id/bSub" ^^ 

instead

 android:id=" +@id /bSub" ^^ 
+20
source

+ The character must be after the @ character.

 android:id=" +@id /bAdd" to android:id="@+id/bAdd" and also change android:id=" +@id /bSub" to android:id="@+id/bSub" 

OR

you can declare that it

android: id = "@ id / bSub"

but you must declare the bSub value in the ids.xml file located in the values ​​folder.

Example

 <resources> <item type="id" name="bSub" /> 
+3
source

use @+id/yourId instead of @id/yourId

+1
source

All Articles