System.ArgumentException: type 参数名称: 类型不是从 java 类型派生的
System.ArgumentException: type Parameter name: Type is not derived from a java type
你好我有一个 android 应用程序,它是用 xamrian native 和 xamrian 形式编写的 我试图让应用程序打开我在 xamrian 形式中做的页面,当用户点击这个按钮时案例 button_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));
}
}
}
任何帮助都会很棒!
提前致谢! :)
最终的问题是我更改的 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
{
现在不会崩溃了!
你好我有一个 android 应用程序,它是用 xamrian native 和 xamrian 形式编写的 我试图让应用程序打开我在 xamrian 形式中做的页面,当用户点击这个按钮时案例 button_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));
}
}
}
任何帮助都会很棒!
提前致谢! :)
最终的问题是我更改的 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
{
现在不会崩溃了!