gpt4 book ai didi

android - '缺少类型或命名空间名称'

转载 作者:行者123 更新时间:2023-12-04 00:12:04 24 4
gpt4 key购买 nike

我按照正确的步骤在 xamarin studio 中开发了一个应用程序,如图(https://developer.xamarin.com/guides/android/getting_started/hello,android/hello,android_quickstart/)
但是,在构建解决方案后,有 11 个错误为
1.'类型或命名空间名称安卓找不到。(您是否缺少 using 指令或程序集引用?)'
2.'类型或命名空间名称 Activity 找不到。(您是否缺少 using 指令或程序集引用?)'
3.'类型或命名空间名称 bundle 找不到。(您是否缺少 using 指令或程序集引用?)'
如何摆脱这些错误?请帮忙

这是代码——

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

namespace PhoneWord
{
[Activity (Label = "PhoneWord", MainLauncher = true, Icon ="@drawable/icon")]
public class MainActivity : Activity
{
int count = 1;

protected override void OnCreate (Bundle bundle)
{
base.OnCreate (bundle);

// Set our view from the "main" layout resource
SetContentView (Resource.Layout.Main);


// Get our UI controls from the loaded layout:
EditText phoneNumberText = FindViewById<EditText>(Resource.Id.PhoneNumberText);
Button translateButton = FindViewById<Button>(Resource.Id.TranslateButton);
Button callButton = FindViewById<Button>(Resource.Id.CallButton);
// Disable the "Call" button
callButton.Enabled = false;

// Add code to translate number
string translatedNumber = string.Empty;

translateButton.Click += (object sender, EventArgs e) =>
{
// Translate user's alphanumeric phone number to numeric
translatedNumber = Core.PhonewordTranslator.ToNumber(phoneNumberText.Text);
if (String.IsNullOrWhiteSpace(translatedNumber))
{
callButton.Text = "Call";
callButton.Enabled = false;
}
else
{
callButton.Text = "Call " + translatedNumber;
callButton.Enabled = true;
}
};

// Get our button from the layout resource,
// and attach an event to it
/*Button button = FindViewById<Button> (Resource.Id.myButton);

button.Click += delegate {
button.Text = string.Format ("{0} clicks!", count++);
};*/
}
}
}

谢谢

最佳答案

我通过添加对

Mono.Android.dll

位于:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\ReferenceAssemblies\Microsoft\Framework\MonoAndroid\v8.1\

关于android - '缺少类型或命名空间名称',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33451871/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com