Forum Xamarin.Android


The Xamarin Forums have officially moved to the new Microsoft Q&A experience. Microsoft Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

To create new threads and ask questions head over to Microsoft Q&A for .NET and get involved today.

Unknown Identifier - Resource File

PaulMouraPaulMoura USUniversity ✭✭

My Android project compiles, deploys to the emulator, but throws an exception why trying to call a static field from the Resource file. When I add a break point on the line making a call to Resource.Layout.Login (Login is a axml file) it says "Resource.Layout.Login = Unknown identifier: Resource". This originally was working. I don't know what caused this to start happening. I have been able to make calls to Resource.Layout.Login in previous tests. What could cause this? How do I fix?

Best Answer


  • xCyborgxCyborg USMember ✭✭

    @PaulMoura said:
    I didn't realize that the line of code making a call to the resource file was still getting a result and the SetContentView() was what was causing the exception because it was being called on a separate thread. Simple overlook.

    Do you mind elaborating more, what did you do to break it. I have the same problem:(

  • PaulMouraPaulMoura USUniversity ✭✭

    I don't remember now what I had done to break it. Can you post your code? If I see something familiar, I might be able to point it out.

  • KianoushMoradianKianoushMoradian USMember ✭✭

    I fixed the issue by moving setContentView() to the top of all identifiers.

    Shoubd be the first --> SetContentView(Resource.Layout.Main);
    Then --> myUsername = FindViewById(Resource.Id.username);

Sign In or Register to comment.