你好我有一个用xamrian native和xamrian两种形式编写的android应用程序我试图让应用程序打开我用xamrian表单做的页面,当用户点击这个例子中的按钮时按钮_1然而当我运行时这在设备上然后单击所述按钮我遇到此错误后出现崩溃:
System.ArgumentException: type Parameter name: Type is not derived from a java type.
这是我的代码,页面上有按钮:
using Android.App;
using Android.Content;
using Android.Views;
using Android.Widget;
using Android.OS;
using Xamarin.Forms.Platform.Android;
namespace ReadyMo.Droid
{
[Activity(Label = "ReadyMO", MainLauncher = true, Icon = "@drawable/icon")]
public class MainActivityHomeView : FormsApplicationActivity
{
Button button;
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
// Set our view from the "main" layout resource
SetContentView(Resource.Layout.Main);
//This is the button im having issues with!!!!!!
//Code That opens the Settings Activity
button = FindViewById<Button>(ReadyMo.Droid.Resource.Id.button_1);
button.Click += (sender, e) => {
// this is our Xamarin.Forms screen
StartActivity(typeof(SettingsView));
};
}
//Code That Opens The Tips Activity!
[Java.Interop.Export("Tips")] // The value found in android:onClick attribute.
public void btnOneClick1(View v) // Does not need to match value in above attribute.
{
StartActivity(typeof(Tips));
}
//Code That Opens The Contact Activity!
[Java.Interop.Export("contact")] // The value found in android:onClick attribute.
public void btnOneClick2(View v) // Does not need to match value in above attribute.
{
StartActivity(typeof(Contact));
}
//Code That Opens The Modot Activity!
[Java.Interop.Export("modot")] // The value found in android:onClick attribute.
public void btnOneClick3(View v) // Does not need to match value in above attribute.
{
StartActivity(typeof(Modot));
}
//Code That Opens The Weather Activity!
[Java.Interop.Export("wether")] // The value found in android:onClick attribute.
public void btnOneClick4(View v) // Does not need to match value in above attribute.
{
StartActivity(typeof(Weather));
}
//Code That sends a email to mosema@sema.dps.mo.gov
[Java.Interop.Export("email")] // The value found in android:onClick attribute.
public void btnOneClick5(View v) // Does not need to match value in above attribute.
{
var email = new Intent(Android.Content.Intent.ActionSend);
email.PutExtra(Android.Content.Intent.ExtraEmail, new string[] { "mosema@sema.dps.mo.gov" });
email.PutExtra(Android.Content.Intent.ExtraSubject, "SEMA");
email.PutExtra(Android.Content.Intent.ExtraText, "Sent Using The ReadyMO App");
email.SetType("message/rfc822");
StartActivity(email);
}
//Code That Opens Calls The State Emergency Management Agency !
[Java.Interop.Export("call")] // The value found in android:onClick attribute.
public void btnOneClick6(View v) // Does not need to match value in above attribute.
{
var uri = Android.Net.Uri.Parse("tel:5735269100");
var intent = new Intent(Intent.ActionDial, uri);
StartActivity(intent);
}
//Code That Opens The Fax Activity!
[Java.Interop.Export("fax")] // The value found in android:onClick attribute.
public void btnOneClick7(View v) // Does not need to match value in above attribute.
{
StartActivity(typeof(Fax));
}
}
}
任何帮助都会很棒!
提前致谢! :)
答案 0 :(得分:0)
最终成为问题的是我改变了FormsApplicationActivity:
[Activity(Label = "ReadyMO", MainLauncher = true, Icon = "@drawable/icon")]
public class MainActivityHomeView : FormsApplicationActivity
{
为:
[Activity(Label = "ReadyMO", MainLauncher = true, Icon = "@drawable/icon")]
public class MainActivityHomeView : Activity
{
现在它不会崩溃!