Visual Studio 2015 - Xamarin - Android - Getting “resource.id does not contain a definition for xxx” when I try to do anything in the .cs file

前端 未结 17 1469
后悔当初
后悔当初 2020-12-30 07:21

Adding Additional Activity .cs and Layout axml Using Visual Studio 2015.

I\'m very new to Xamarin and Android

相关标签:
17条回答
  • 2020-12-30 07:41

    Check the Resource.Designer class file. There will be a class like public partial class Id. There the integer IDs of the controls are written. Use them instead of Resource.Id

    0 讨论(0)
  • 2020-12-30 07:42

    Check if you are missing these namespaces in your layout file -

    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    
    0 讨论(0)
  • 2020-12-30 07:43

    (VS 2019) I did the previous solutions and nothing, I had the same problem and the solution for me was to remove '&' from the text of TextView, I was trying to Set the text to "text&text" even &&(I though it was like mnemonics as in WindowsForms) didn't work so I had to remove it and it fixed.

    0 讨论(0)
  • 2020-12-30 07:43

    The best solution I have found is to build solution. Choose Build solution from Build menu (or Ctrl+Shift+B). This action will resolve the issue.

    0 讨论(0)
  • 2020-12-30 07:46

    Like Maniacz said, in VS 2019 I just had to change the XML to axml extensión to the layout in layout folder under resources

    0 讨论(0)
  • 2020-12-30 07:47

    What did work for me (Visual Studio 2017, opening an old Xamarin project):

    1. Delete obj and bin folders, build.
    2. If errors, restart Visual Studio (I know the pain).
    3. Build again

    Now the Resource will be visible (of course, if you defined it correctly).

    0 讨论(0)
提交回复
热议问题