7

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!

2
  • 6
    I have never seen @+string used anywhere in Android. I have seen @+id used, to allocate a new ID resource. Please provide some sample code that uses @string that is giving you errors, and supply the actual error. Commented Sep 1, 2012 at 14:20
  • Where have you ever used @+string? Commented Sep 1, 2012 at 14:21

3 Answers 3

6

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

Sign up to request clarification or add additional context in comments.

Comments

1

@String are the values retreived from the strings file.

Comments

0

hey guys use the newest elipse, there's a bit of difference between it and the old ones. I guess zapl's answer is correct, the + sign is to add it to the references. Cheers guys!

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.