What does "@ + android: id / title" mean?

In normal mode, we should use @+id/ to determine id and use @id to refer to id. Today I found @+android:id/title in apps/settings/res/layout/preferenc_progress.xml .

How to understand this and how to use it?

+4
source share
4 answers

It is used for resources shipped with the SDK.

You can take a look at them by viewing

[PATH TO ANDROID SDK]/platforms/android-[VERSION]/data/res

Using android in android.R.whatever , you simply specify the R file to search. For more information, you should read Access to platform resources .

+4
source

I have never met this method of passing id, but theoretically this means adding a new package id title to android . This way you can use it in your code, for example android.R.id.title . But I'm not sure if the resource compiler will really create any identifier in the android package. I think it can only be used with predefined identifiers. But I will give you a more accurate answer later, when I can check it.

EDIT : I checked it and found some differences. First, if you define the Android identifier using @+android:id/some_id , which is already in the SDK, that identifier will not be defined in your R.java file. If it is not present in the SDK, it will be defined in R.java, but with a different value. Secondly, if you try to convert the id from its string representation to an int value, the Resources.getIdentifier() method will return 0 in the case of the @+android:id format.

0
source

I think he does the same. This is just a more formal way of saying this by indicating where the namespace is.

0
source

This means that it will create an identifier in your resource file.

-1
source

All Articles