I have a library that contains resources. When the class is called from the application the layout id's and widget id's are incorrect.
In the library I have an activity that calls SetContentView(Resource.Layout.login). Instead of the correct layout being displayed the layout it is displaying is the layout that corresponds to the number defined in the application's Resource.Designer.cs (CustomerDetail).
In the Library I have:
public static int login = 2130903059;
In the application I have:
public const int CustomerDetail = 2130903059;
public const int login = 2130903110;
If I change the code to SetContentView(2130903110) then it works.
Clearly a disjoint in the compiler in determining what the value should be.
I don't see a work around and I need this ASAP as this proper library functionality is mandatory for the project that I'm in the middle of.
Of further note when debugging, SetContentView(Resource.Layout.login) is showing 2130903110 in quick watch because it is getting confused between Library.Resource.Layout and Application.Resource.Layout. i.e. quick watch is showing Application.Resource.Layout instead of Library.Resource.Layout.
I was able to figure it out. I needed to call Resource.UpdateIdValues() in the constructor of my main activity. Is there no way that this could be done automatically?
Oops! You're right, thanks for pointing it out. I totally forgot to add resource ID initializer code as in each resource designer's static constructor. It is fixed in our codebase and will be included in the next major release.
Until the fix arrives, please add call to Android.Runtime.ResourceIdManager.UpdateIdValues() somewhere around your app bootstrap (I added this method exactly for this purpose).