Sometimes, when I want to refer a value to a string reference I use @string/blabla, but sometimes, it gives me an error that I can run the code unless i change @string to @+string
What's the difference between them?
Any answer would be so helpful. Thanks in Advance!
3 Answers
The + means that this identifier will be added to the resources. You declare that it exists somewhere and use it at the same time. Not sure if that really applies to strings but I guess it does. It would explain why you get no error.
And I doubt it is good to use a + to make it work. You could end up with a string declaration with no actual string content which will likely result in a crash.
If it is not working without the + try building / refreshing your project. If the string is defined in one of your xml files you should be able to use @string
@+stringused anywhere in Android. I have seen@+idused, to allocate a new ID resource. Please provide some sample code that uses@stringthat is giving you errors, and supply the actual error.