美文网首页Android
NavigationView设置监听器无效解决

NavigationView设置监听器无效解决

作者: 巨蟹豆浆油条啦 | 来源:发表于2017-05-07 20:16 被阅读0次

NavigationView设置监听器无效解决

  • 对于设置NavigationItemSelectListener无效的问题,测试后之后发现是由于在XML中NavigationView没有写在XML最后的原因导致,期间有试过在Menu设置checkable、enable,都不成功,最后抱着试一试的想法改了XML中的NavigationView到文件最后才成功,特此记录!

    2017.05.07

<?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"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/main_drawerLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".mvp.view.activity.MainActivity"
    >

  <android.support.design.widget.AppBarLayout
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:clipToPadding="true"
      android:fitsSystemWindows="true"
      >

    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar_main"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:navigationIcon="@mipmap/ic_reorder_black_24dp"
        >
    </android.support.v7.widget.Toolbar>

    <FrameLayout
        android:padding="5dp"
        android:id="@+id/mainFrame"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        ></FrameLayout>

  </android.support.design.widget.AppBarLayout>


  <android.support.design.widget.NavigationView
      android:id="@+id/nav_main"
      android:layout_width="wrap_content"
      android:layout_height="match_parent"
      android:layout_gravity="start"
      android:fitsSystemWindows="true"
      app:headerLayout="@layout/headlayout"
      app:itemBackground="?android:attr/selectableItemBackground"
      app:menu="@menu/navmenu"
      ></android.support.design.widget.NavigationView>

</android.support.v4.widget.DrawerLayout>


相关文章

网友评论

    本文标题:NavigationView设置监听器无效解决

    本文链接:https://www.haomeiwen.com/subject/nukptxtx.html