gpt4 book ai didi

Android.Views.InflateException : Binary XML file line #17: Error inflating class android. 支持.design.internal.NavigationMenuItemView

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:46:58 26 4
gpt4 key购买 nike

我在使用 Xamarin 的 Android 项目中使用 Material 抽屉导航。我一直在尝试将两个 Framelayout 添加到 drawerlayout 中,以便我可以切换不同 fragment 的内容,请参见下面的 xml:

 <?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:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<!-- This LinearLayout represents the contents of the screen -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<!-- The ActionBar displayed at the top -->
<include
layout="@layout/toolbar"
android:id="@+id/toolbar" />
<!-- The main content view where fragments are loaded -->
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
android:id="@+id/scrollview">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<FrameLayout
android:id="@+id/search_frame"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<FrameLayout
android:id="@+id/blah"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
</ScrollView>
</LinearLayout>
<!-- The navigation drawer that comes from the left -->
<!-- Note that `android:layout_gravity` needs to be set to 'start' -->
<android.support.design.widget.NavigationView
android:id="@+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
app:menu="@menu/drawer_view"
app:itemTextColor="#FFFFFF"
app:itemIconTint="#FFFFFF"
android:background="#464646"/>
</android.support.v4.widget.DrawerLayout>

主要 Activity :

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

SetContentView(Resource.Layout.activity_main);

drawerLayout = FindViewById<DrawerLayout>(Resource.Id.drawer_layout);
// Setting up the toolbar
var toolbar = FindViewById<Toolbar>(Resource.Id.toolbar);
SetSupportActionBar(toolbar);
SupportActionBar.SetTitle(Resource.String.ApplicationName);
SupportActionBar.SetDisplayHomeAsUpEnabled(true);
SupportActionBar.SetDisplayShowHomeEnabled(true);

// Attach item selected handler to navigation view
var navigationView = FindViewById<NavigationView>(Resource.Id.nav_view);
navigationView.NavigationItemSelected += NavigationView_NavigationItemSelected;

// Create ActionBarDrawerToggle button and add it to the toolbar
var drawerToggle = new Android_Support.V7.App.ActionBarDrawerToggle(this, drawerLayout, toolbar, Resource.String.open_drawer, Resource.String.close_drawer);
drawerLayout.SetDrawerListener(drawerToggle);
drawerToggle.SyncState();
}

我收到以下错误:Android.Views.InflateException: Binary XML file line #17: Error inflating class android.support.design.internal.NavigationMenuItemView

我尝试移动 Drawerlayout 中的元素,但错误仍然存​​在。我查看了 Android 文档,一切似乎都是正确的。我还检查了我是否拥有最新版本的 Design 和 AppCompact 库

最佳答案

前段时间我遇到了同样的问题,我不知道到底是什么原因造成的,但我可以告诉你我做了什么,也许它可以帮助你。

  1. 我的手机内存快满了,所以我删除了一些应用
  2. 我卸载了出现错误的应用
  3. 我清理并重建了项目
  4. 再次运行它。

瞧!它奏效了。

关于Android.Views.InflateException : Binary XML file line #17: Error inflating class android. 支持.design.internal.NavigationMenuItemView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35887389/

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