0
VAR mToolbar = FindViewById(Resource.Id.toolbar);例外が呼び出し私は例外がで呼び出しのターゲットによってスローされていましたxamarin.android
のターゲットによってスロー てきました
DrawerLayout drawerLayout;
NavigationView navigationView;
protected override void OnCreate (Bundle savedInstanceState)
{
base.OnCreate (savedInstanceState);
// Set our view from the "main" layout resource
//ActionBar.NavigationMode = ActionBarNavigationMode.Tabs;
SetContentView (Resource.Layout.Main);
var mToolbar= FindViewById<Toolbar> (Resource.Id.toolbar);
//Toolbar will now take on default action bar chacracteritics
SetActionBar(mToolbar);
ActionBar.Title = "home";
//Enable suppport action bar to display hamburger
ActionBar.SetHomeAsUpIndicator(Resource.Drawable.icon_hambuger);
ActionBar.SetDisplayHomeAsUpEnabled (true);
//Set menu hambuger
ActionBar.SetHomeAsUpIndicator (Resource.Drawable.icon_home);
ActionBar.SetDisplayHomeAsUpEnabled (true);
drawerLayout = FindViewById<DrawerLayout> (Resource.Id.drawer_layout);
navigationView = FindViewById<NavigationView> (Resource.Id.nav_view);
navigationView.NavigationItemSelected += (sender, e) => {
e.MenuItem.SetChecked (true);
//react to click here and swap fragments or navigate
drawerLayout.CloseDrawers();
};
// Add tabs to tabbar
//AddTab ("Genres", new GenerFragment());
//AddTab ("Explore", new ExploreFragment());
//AddTab ("Audio", new AudioFragment());
}
//Event Selected on nav menu
public override bool OnOptionsItemSelected (IMenuItem item)
{
switch (item.ItemId)
{
case Android.Resource.Id.Home:
drawerLayout.OpenDrawer (Android.Support.V4.View.GravityCompat.Start);
return true;
}
return base.OnOptionsItemSelected (item);
}
// Add options menu on toolbar
public override bool OnCreateOptionsMenu(Android.Views.IMenu menu)
{
MenuInflater.Inflate (Resource.Menu.Action_menu, menu);
return base.OnCreateOptionsMenu (menu);
}
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:id="@+id/drawer_layout">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?attr/actionBarSize"
android:background="?attr/colorPrimary"
android:titleTextColor="@android:color/background_light" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" />
</RelativeLayout>
<android.support.design.widget.NavigationView
android:id="@+id/nav_view"
android:layout_height="match_parent"
android:layout_width="wrap_content"
android:layout_gravity="start"
app:headerLayout="@layout/drawer_header"
app:menu="@menu/navmenu" />
</android.support.v4.widget.DrawerLayout>
Xamarin.androidにこれまで以上に問題があります。私はどこに誤りがあるのか分かりません。古いエラーを修正し、新しいエラーを表示しました。@@ それを解決する方法。ありがとう。
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.InvalidProgramException: Missing or incorrect header for method .ctor
at at (wrapper managed-to-native) System.Reflection.MonoCMethod:InternalInvoke (System.Reflection.MonoCMethod,object,object[],System.Exception&)
at System.Reflection.MonoCMethod.InternalInvoke (System.Object obj, System.Object[] parameters) [0x00002] in /Users/builder/data/lanes/3053/a94a03b5/source/mono/mcs/class/corlib/System.Reflection/MonoMethod.cs:644
--- End of inner exception stack trace ---
at System.Reflection.MonoCMethod.InternalInvoke (System.Object obj, System.Object[] parameters) [0x00016] in /Users/builder/data/lanes/3053/a94a03b5/source/mono/mcs/class/corlib/System.Reflection/MonoMethod.cs:650
at System.Reflection.MonoCMethod.DoInvoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00089] in /Users/builder/data/lanes/3053/a94a03b5/source/mono/mcs/class/corlib/System.Reflection/MonoMethod.cs:635
at System.Reflection.MonoCMethod.Invoke (BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in /Users/builder/data/lanes/3053/a94a03b5/source/mono/mcs/class/corlib/System.Reflection/MonoMethod.cs:663
at System.Reflection.ConstructorInfo.Invoke (System.Object[] parameters) [0x00000] in /Users/builder/data/lanes/3053/a94a03b5/source/mono/mcs/class/corlib/System.Reflection/ConstructorInfo.cs:62
at Java.Interop.TypeManager.CreateProxy (System.Type type, IntPtr handle, JniHandleOwnership transfer) [0x00059] in /Users/builder/data/lanes/3053/a94a03b5/source/monodroid/src/Mono.Android/src/Java.Interop/TypeManager.cs:303
at Java.Interop.TypeManager.CreateInstance (IntPtr handle, JniHandleOwnership transfer, System.Type targetType) [0x0012c] in /Users/builder/data/lanes/3053/a94a03b5/source/monodroid/src/Mono.Android/src/Java.Interop/TypeManager.cs:277
at Java.Lang.Object.GetObject (IntPtr handle, JniHandleOwnership transfer, System.Type type) [0x000e5] in /Users/builder/data/lanes/3053/a94a03b5/source/monodroid/src/Mono.Android/src/Java.Lang/Object.cs:371
at Java.Lang.Object.GetObject[T] (IntPtr handle, JniHandleOwnership transfer) [0x0001a] in /Users/builder/data/lanes/3053/a94a03b5/source/monodroid/src/Mono.Android/src/Java.Lang/Object.cs:342
at Java.Lang.Object.GetObject[T] (IntPtr handle, JniHandleOwnership transfer) [0x00000] in /Users/builder/data/lanes/3053/a94a03b5/source/monodroid/src/Mono.Android/src/Java.Lang/Object.cs:334
at Android.App.Activity.FindViewById (Int32 id) [0x00077] in /Users/builder/data/lanes/3053/a94a03b5/source/monodroid/src/Mono.Android/platforms/android-23/src/generated/Android.App.Activity.cs:1939
at Android.App.Activity.FindViewById[T] (Int32 id) [0x00000] in /Users/builder/data/lanes/3053/a94a03b5/source/monodroid/src/Mono.Android/src/Android.App/Activity.cs:12
at SoundCloud.MainActivity.OnCreate (Android.OS.Bundle savedInstanceState) [0x00019] in /Users/hoanglethien/Desktop/SoundCloud/SoundCloud/MainActivity.cs:29
at Android.App.Activity.n_OnCreate_Landroid_os_Bundle (IntPtr jnienv, IntPtr native__this, IntPtr native_savedInstanceState) [0x00011] in /Users/builder/data/lanes/3053/a94a03b5/source/monodroid/src/Mono.Android/platforms/android-23/src/generated/Android.App.Activity.cs:2857
at at (wrapper dynamic-method) System.Object:d02a4f71-fdeb-4fc8-8465-eedc540c9cd9 (intptr,intptr,intptr)
この例外の完全なスタックトレースを含めてください。 –
詳細情報を更新しました –