I followed every step properly to develop an app in xamarin studio as shown in(https://developer.xamarin.com/guides/android/getting_started/hello,android/hello,android_quickstart/) But, After building the solution there 11 errors as 1.'The type or namespace name Android could not be found.(Are you missing a using directive or an assembly reference?)' 2.'The type or namespace name Activity could not be found.(Are you missing a using directive or an assembly reference?)' 3.'The type or namespace name Bundle could not be found.(Are you missing a using directive or an assembly reference?)' How to get rid of these errors? Please help
Here's the code---
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++);
};*/
}
}
}
Thank you
I solved the issue by adding a reference to
Mono.Android.dll
Located under :
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\ReferenceAssemblies\Microsoft\Framework\MonoAndroid\v8.1\
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With