I want to know what is the different of declaring a variable or id as
@android:id/
@+id/
When I set @+id/tabhost
on Tabhost, it keep giving me error, but if I set @android:id/
. it work.
I want to know what is the different of declaring a variable or id as
@android:id/
@+id/
When I set @+id/tabhost
on Tabhost, it keep giving me error, but if I set @android:id/
. it work.
@+id
creates a new ID. Android does not know this new ID, so the app crashes.
@id
uses an existing ID from inside your app.
@android/id
uses an existing ID from the Android framework. Android already knows this ID, it can access the corresponding View
and the app will not crash.
Resource ID in Android are specific to a your package.
@+id/name will create a resource ID in your package with the name "name" and give it a unique ID, you can also check that ID in R.java file. In code, you can use like R.id.name.
@android:id/name this will use the ID "name" from the package specified by android (in code you can use like android.R.id.name.) @android:id/ is use to get id from existing packages.
And tabhost are specified in the android package that's why its giving error @+id/tabhost ,so you have to use @android:id/