Resource.Id is not finding my button

NeidennXNeidennX Member ✭✭

When i use FindViewById<Button>(Resource.Id.) is not finding the button that i need to use.

Here is an screenshot of my layout:

and here is an screenshot of my code

Can anybody help me please, this is driving me crazy :'(

Best Answer

Answers

  • jezhjezh Member, Xamarin Team Xamurai

    You can try to check if there is some problem in the layout, if there is any problem with layout, it will cause such problem.

    If the problem still persist, you can try to delete the bin folders and the obj folders and rebuild it . If it doesn’t work ,try to restart the VS .

    Besides,sometimes even if the APP is built successfully, the code will also get a red error message and you just ignore it.

  • ChristopheBERNARDChristopheBERNARD BEMember ✭✭✭✭

    Hello all
    @NeidennX try perhpas to close vs and re open it ..
    Sometimes i have this issue also with vs 2017 i close and open it again and often it solve my problem..
    Also , perhpas try to create a blank project rather than other

  • NeidennXNeidennX Member ✭✭

    I've already tried cleaning, building, rebuilding the code, close and open the project, and nothing seems to work, basically i already tried all of what you guys mentioned and nothing seems to work :/

  • jezhjezh Member, Xamarin Team Xamurai

    Could you please share a basic demo so that we can test on our side?

  • NeidennXNeidennX Member ✭✭
    edited July 31

    Yes off course, the thing is that from nowhere is showing new errors when i try to compile it, errors that i'dont undestand, but maybe you can help me out, here is the demo

    https://mega.nz/#F!7xtl0KoS!gnOyP1LV1D2Z_eQdX_SQ9w

    i uploaded it to Mega cause the file was a little big.

    Thanks in advance

  • jezhjezh Member, Xamarin Team Xamurai

    When I built your app , I found there are several problems:
    1. the layout below is not well-format

         <Button
          android:id="@+id/BtnRegEstudiante"
          android:text="Registro de Estudiantes"
          android:layout_width="400px"
          android:layout_height="150px"
          android:layout_marginTop="250px"
          android:layout_marginLeft"180px"/>  
    

    Note: change android:layout_marginLeft"180px" to android:layout_marginLeft="180px"
    2. after modified the layout ,then I found the errors below

    So I just uninstalled the Nuget:LiveXAML, after uninstalled the nuget, the app will been rebuilt successfully.

  • jezhjezh Member, Xamarin Team Xamurai

    Here is the demo you post which could run nornally. I have modifed some places I mentioned above.
    The effect is as follows:

Sign In or Register to comment.