Tuesday, 26 June 2018

New resource id declaration without the plus sign

This documentation always puzzles me:

For the ID value, you should usually use this syntax form: "@+id/name". The plus symbol, +, indicates that this is a new resource ID and the aapt tool will create a new resource integer in the R.java class, if it doesn't already exist. For example:

<TextView android:id="@+id/nameTextbox"/>

I've been programming for quite a while now. However, I've never encountered any case wherein I have to use the ID declaration without the plus sign. It is also counter-intuitive. IDs are supposed to be unique!

Any good use-case for this? Why would one want to re-use the same resource id name?



from New resource id declaration without the plus sign

No comments:

Post a Comment