0

I compile this,

        <FrameLayout
        android:id="@+android:id/realtabcontent"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"/>

in http://androidxref.com/4.4.4_r1/xref/development/samples/ApiDemos/res/layout/fragment_tabs_fragment.xml#44

encounter errors:

Description Resource    Path    Location    Type
error: creating resource for external package android: id/realtabcontent.   fragment_tabs_fragment.xml  /ApiDemos/res/layout    line 43 Android AAPT Problem
error: Error: No resource found that matches the given name (at 'id' with value '@+android:id/realtabcontent'). fragment_tabs_fragment.xml  /ApiDemos/res/layout    line 43 Android AAPT Problem
note: did you mean to use @+id instead of @+android:id? fragment_tabs_fragment.xml  /ApiDemos/res/layout    line 43 Android AAPT Problem
Unparsed aapt error(s)! Check the console for output.   ApiDemos        Unknown Android Packaging Problem

if I change to

        <FrameLayout
        android:id="@+id/realtabcontent"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"/>

compile successfully.

What's difference of android:id="@+android:id/realtabcontent" and android:id="@+id/realtabcontent"?

Victor S
  • 4,021
  • 15
  • 43
  • 54
  • @Blackbelt is `@+android:id` and `@+id` are same? – Apurva Mar 23 '15 at 09:05
  • possible duplicate of [what is the difference betwenn @id/ and @+id/ in android?](http://stackoverflow.com/questions/5731414/what-is-the-difference-betwenn-id-and-id-in-android) – kiranpradeep Mar 23 '15 at 09:11
  • http://stackoverflow.com/questions/3264235/what-is-different-between-id-androidlist-and-id-androidlist/29207110#29207110 – IntelliJ Amiya Mar 23 '15 at 09:46
  • 1
    @Apurva **NO**. the prefix `android:` means it's a system element, not a custom defined one – Phantômaxx Mar 23 '15 at 09:54
  • it's not a duplicate question (at least I didn't find any similar one) --> does anyone of you know why to use @+android:id/XX and not one of @android:id/XX or @+id/XX or @id/XX or @id/android:XX ...? – ahmed_khan_89 Sep 26 '18 at 09:45

2 Answers2

0

i think android:id="@+android:id/realtabcontent" is wrong. When you want to give something an ID you generally use android:id="@+id/your_view" but when you want the android System to recognize a particular view in your xml and you do not have to tell it(the system) explicitly, you use android:id="@android:id/listview"

Or for example you are creating a custom drawable for SEEKBAR you'd give IDS like so

<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:id="@android:id/background"
        android:gravity="center_vertical|fill_horizontal">
        <shape android:shape="rectangle"
            android:tint="#51F8F5F5">
            <corners android:radius="2dp"/>
            <size android:height="10dp" />
            <solid android:color="#ffd600" />
        </shape>
    </item>
    <item android:id="@android:id/progress"
        android:gravity="center_vertical|fill_horizontal">
        <scale android:scaleWidth="100%">
            <selector>
                <item android:state_enabled="false"
                    android:drawable="@android:color/transparent" />
                <item>
                    <shape android:shape="rectangle"
                        android:tint="#FFFFFF">
                        <corners android:radius="2dp"/>
                        <size android:height="10dp" />
                        <solid android:color="#FFFFFF" />
                    </shape>
                </item>
            </selector>
        </scale>
    </item>
</layer-list>

now notice, android:id="@android:id/background" ...&.. android:id="@android:id/progress"

these are for the android to recognize these two items and do not require telling it explicity that this item is background and that item is progress.

hope it might help someone, if yes, it least it deserves a +1

Nasib
  • 1,173
  • 1
  • 13
  • 23
-1

It creates a unique identifier for that element that you can find it by when you are using findViewById(R.id.___)

As you can see from difference between @id and @android:id, @android:id refers to specific pre-defined namespaces in the Android framework.

Community
  • 1
  • 1
Phillip Godzin
  • 660
  • 1
  • 9
  • 21