Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

android

xml

I am getting an error saying String types not allowed (at 'id' with value ' @id/bAdd')

  • I've cleaned the project.
  • Everything was working earlier, I don't what happened, 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"
    
        />
    

like image 813
AndroidDev Avatar asked Jul 28 '12 10:07

AndroidDev


2 Answers

You can give your id as @+id/bAdd

instead of +@id/bAdd

Also edit in

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

instead of

android:id="+@id/bSub"
            ^^
like image 154
Chintan Raghwani Avatar answered Oct 31 '22 00:10

Chintan Raghwani


+ Symbol must be after @ Symbol.

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 is it

android:id="@id/bSub"

but you have to declare bSub value in ids.xml file located in values folder.

Example

<resources>
  <item type="id" name="bSub" />
like image 31
Chirag Avatar answered Oct 31 '22 00:10

Chirag