官方的文件 Declaring Layout 中有以下說明:
The at-symbol (@) at the beginning of the string indicates that the XML parser should parse and expand the rest of the ID string and identify it as an ID resource. The plus-symbol (+) means that this is a new resource name that must be created and added to our resources (in the R.java file). There are a number of other ID resources that are offered by the Android framework. When referencing an Android resource ID, you do not need the plus-symbol, but must add the android package namespace, like so:
android:id="@android:id/empty"
意即,@ 表示 XML parser 需要將接下來的字串轉換成 ID resource,其中 @+ 表示這是新的 resource name,必須新建到 R.java 內;@android:id 則表示指向的這個 resource name 是已經存在的 resource。
沒有留言:
張貼留言