Xamarin /视觉工作室为Mac:axml文件不会出现在intellisense类文件和抛出错误构建

问题描述:

嗨,大家好我正在编写一个应用程序在Visual Studio的Mac/Xamarin与C#和我试图添加我的axml文件(布局)命名为“Dialog_SignUp”到我的课堂来调用它,但我不明白为什么我的intellisense无法识别它,当我尝试构建它时,我有一个错误,说“资源布局不包含定义Dialog_SignUp(CS0117)“。Xamarin /视觉工作室为Mac:axml文件不会出现在intellisense类文件和抛出错误构建

显然,我的文件都存在,它是在文件夹资源/布局/ Dialog_SigbnUP.axml,所以我做了对谷歌的一些研究,但我没有发现任何对这个还是我没有把正确的关键词在谷歌上。

希望有人能帮助我。谢谢。

我的班级DialogSignUp.cs

using System; 
using Android.App; 
using Android.Widget; 
using Android.OS; 
using Android.Views; 
using Android.Runtime; 

namespace LoginSystem 
{ 
    public class DialogSignUp : DialogFragment 
    { 
     public DialogSignUp() 
     { 
     } 

     public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) 
     { 
      base.OnCreateView(inflater, container, savedInstanceState); 

      var view = inflater.Inflate(Resource.Layout.Dialog_SignUp, container, false); 

      return view; 
     } 
    } 
} 

我的班级Dialog_SignUp.axml

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:background="#DEDEDC" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:minWidth="300dp" 
    android:minHeight="400dp"> 
    <EditText 
     android:id="@+id/txtFirstName" 
     android:layout_width="match_parent" 
     android:layout_height="35dp" 
     android:background="@drawable/edit_text_style" 
     android:layout_marginBottom="10dp" 
     android:layout_marginLeft="20dp" 
     android:layout_marginRight="20dp" 
     android:layout_marginTop="25dp" 
     android:hint="First Name" 
     android:paddingLeft="10dp" 
     android:textColor="#000" /> 
    <EditText 
     android:layout_below="@id/txtFirstName" 
     android:inputType="textEmailAddress" 
     android:layout_width="match_parent" 
     android:layout_height="35dp" 
     android:id="@+id/txtEmail" 
     android:background="@drawable/edit_text_style" 
     android:layout_marginBottom="10dp" 
     android:layout_marginLeft="20dp" 
     android:layout_marginRight="20dp" 
     android:hint="Email" 
     android:paddingLeft="10dp" 
     android:textColor="#000" /> 
    <EditText 
     android:inputType="textPassword" 
     android:layout_width="match_parent" 
     android:layout_height="35dp" 
     android:id="@+id/txtPassword" 
     android:background="@drawable/edit_text_style" 
     android:layout_marginLeft="20dp" 
     android:layout_marginRight="20dp" 
     android:hint="Password" 
     android:paddingLeft="10dp" 
     android:textColor="#000" 
     android:layout_below="@id/txtEmail" /> 
    <RelativeLayout 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_below="@id/txtPassword" 
     android:layout_marginTop="50dp"> 
     <Button 
      android:text="Sign Up!" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:id="@+id/btnDialogEmail" 
      android:textSize="20dp" 
      android:textColor="#fff" 
      android:textStyle="bold" 
      android:paddingLeft="5dp" 
      android:paddingBottom="5dp" 
      android:paddingRight="5dp" 
      android:height="70dp" 
      android:paddingTop="2dp" 
      android:background="@drawable/ButtonSignUpStyle" 
      android:layout_centerHorizontal="true" 
      android:layout_marginLeft="30dp" /> 
    </RelativeLayout> 
</RelativeLayout> 

在你我会改变文件名中小写用下划线,像“dialog_signup .axml”。理论上两个约定都应该是正确的,但我总是使用小写字母和下划线。

其次,检查你的.csproj里面是否包含文件。应该是这样的:

<AndroidResource Include="Resources\layout\dialog_signup.axml" /> 

<AndroidResource Include="Resources\layout\dialog_signup.axml"> 
    <SubType>Designer</SubType> 
</AndroidResource> 

三,检查,在Resource.designer.cs有一排这样的:

public const int dialog_signup = [int]; 

也许你只需要再次建立Resource.designer.cs

+0

谢谢我会检查,当我回家!但我很确定你是对的。我没有考虑重建resource.designer! – Nehoss