Search code examples
androidbreakpoints

Possible to have same @+id and @string?


I'm new to Android programming. I spent a long time trying to look for a 'phantom line breakpoint' error in my code and I couldn't figure it out till I changed a string resource name.

I have an options.xml menu that contains

<item android:id="@+id/menu_about"
    android:title="@string/menu_about"
    android:icon="@drawable/ic_menu_about"></item>

My question - I have @+id/menu_about and @string/menu_about. is this possible?

Thank you very much


Solution

  • Yes, this is possible.

    R.java itself is organized into some subclasses for strings, ids, drawables etc. It is possible to have two different resources with the same name as they will be members of different classes. However, you cannot have two of the same resources with the same name, like two strings named "foo" for example.