1

why statement android:id="@+id/" keep on appearing everytime I wanted to run my app ? Is there a way to remove it ? Thanks

 <AbsoluteLayout
            android:orientation="vertical" android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:id="@+id/">

Error

Error:(16, 21) Resource id cannot be an empty string (at 'id' with value '@+id/').

I understand that we need to set an id if we want to use it. If I remove it and run, the app still working.But when I run second time, it appears again.

Hoo
  • 1,806
  • 7
  • 33
  • 66
  • AbsoluteLayout. This class was deprecated in API level 3. Use FrameLayout, RelativeLayout or a custom layout instead. http://developer.android.com/intl/ru/reference/android/widget/AbsoluteLayout.html – Mikelis Kaneps Nov 24 '15 at 09:30

1 Answers1

1

The at sign (@) is required when you're referring to any resource object from XML. It is followed by the resource type (id in this case), a slash, then the resource name .

Resource Objects

A resource object is a unique integer name that's associated with an app resource, such as a bitmap, layout file, or string.

Every resource has a corresponding resource object defined in your project's gen/R.java file. You can use the object names in the R class to refer to your resources, such as when you need to specify a string value for the android:hint attribute. You can also create arbitrary resource IDs that you associate with a view using the android:id attribute, which allows you to reference that view from other code.

The SDK tools generate the R.java file each time you compile your app. You should never modify this file by hand.

For more information, read the guide to Providing Resources. The plus sign (+) before the resource type is needed only when you're defining a resource ID for the first time.

You have to set id

android:id="@+id/Your_id

+id Plus sing tells android to add or create a new id in Resources.

Finally

<AbsoluteLayout
        android:orientation="vertical" android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/Your_id">
IntelliJ Amiya
  • 74,896
  • 15
  • 165
  • 198