none
CS0117 C# 'Resource.Id' does not contain a definition for “” RRS feed

  • Question

  • Xamarin Android (Visual Studio 2019 with Xamarin

    SigninActivity.cs

    using System;
    using Android.App;
    using Android.OS;
    using Android.Support.V7.App;
    using Android.Util;
    using Android.Widget;
    
    namespace DBAndroid
    {
        [Activity(Theme = "@style/MyTheme.Login", NoHistory = true, Icon = "@mipmap/ic_launcher")]
        public class SigninActivity : Activity
        {
            EditText email;
            EditText password;
            Button _button;
            protected override void OnCreate(Bundle bundle)
            {
                base.OnCreate(bundle);
                SetContentView(Resource.Layout.Signin);
                email = FindViewById<EditText>(Resource.Id.txtEmail);
                password = FindViewById<EditText>(Resource.Id.txtPassword);
                //var button = FindViewById<FloatingActionButton>(Resource.Id);
                _button = FindViewById<Button>(Resource.Id.btnSignin);
    
                //_button.Click += DoLogin;
            }
        }
    }

    Signin.axml

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
        <EditText
                android:id="@+id/txtEmail"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:hint="电子邮件"
                android:theme="@style/EditTextWhite"
                android:inputType="textEmailAddress"
                android:drawableLeft="@drawable/ic_lock" />
        <EditText
                android:id="@+id/txtPassword"
                android:layout_marginTop="40dp"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:hint="登录密码"
                android:theme="@style/EditTextWhite"
                android:inputType="textPassword"
                android:drawableLeft="@drawable/ic_key" />
        <Button
                android:text="@string/Login"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:id="@+id/btnSignin"
                android:layout_marginTop="50dp"
                android:layout_marginLeft="0dp"
                android:layout_marginRight="0dp"/>
    </LinearLayout>
    

    Friday, July 5, 2019 2:29 AM

All replies

  • Hi Eric,

    Thank you for posting here.

    Based on your description, you could refer to the following steps.

    1. Ensure that the Resource is your namespace.Resource.

    2. Ignore the error message of VS, continue to build (it's vs tools's problem,always notice id can not find, but you can still run).

    3. If still not work after the above two points, delete the content inside the  "Resources/Resource.Designer.cs" file, and then rebuild (delete the contents of the file, not delete the file).

    If you have any question about it, please feel free to let us know.

    Best Regards,

    Jack


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.



    Friday, July 5, 2019 6:44 AM
    Moderator