2015-03-23 3 views
-1

я компилирую это,В чем разница «@ + android: id» и «@ + id»?

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

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

ошибки сталкиваются с:

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 

если я изменяю

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

успешно компилировать.

В чем отличие android: id = "@ + android: id/realtabcontent" и android: id = "@ + id/realtabcontent"?

+0

@Blackbelt - '@ + android: id' и' @ + id' - это то же самое? – Apurva

+0

Возможный дубликат [в чем разница betwenn @ id/и @ + id/in android?] (Http://stackoverflow.com/questions/5731414/what-is-the-difference-betwenn-id-and-id -in-android) – Kiran

+0

http://stackoverflow.com/questions/3264235/what-is-different-between-id-androidlist-and-id-androidlist/29207110#29207110 –

ответ

0

Это создает уникальный идентификатор для этого элемента, который вы можете найти его, когда вы используете findViewById(R.id.___)

Как вы можете видеть из difference between @id and @android:id, @android: идентификатор относится к определенным заранее определенным пространствам имен в Android рамке.