我正在尝试重新创建这个导航抽屉 Example。但是我的应用程序:actionLayout没有处理我希望它工作的项目。它正在研究一个子项My Nav(我把它作为概念证明)。我如何让它也在工作 项目 机器人:标题= “标签”
这是我的drawer_view.xml
`<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto">
<group android:checkableBehavior="single"
android:id="@+id/menu_top">
<item
android:title="Labels"
app:actionLayout="@layout/label_btn">
<!--Button-->
<menu>
<item
android:id="@+id/nav_labels"
android:title="Dynamic Labels" />
<item
android:id="@+id/nav_labels_new"
android:icon="@android:drawable/ic_menu_add"
android:title="Create New Label"
app:actionLayout="@layout/label_btn" />
</menu>
</item>
</group>
<group android:checkableBehavior="single"
android:id="@+id/menu_bottom">
<item
android:id="@+id/nav_manage"
android:icon="@android:drawable/ic_menu_manage"
android:title="Settings"
/>
<item
android:id="@+id/nav_feedback"
android:icon="@android:drawable/ic_menu_slideshow"
android:title="Feedback"
/>
</group>
</menu>`
我的activity_main.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"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context="com.floridapoly.relaystopwatch.MainActivity"
>
<!-- Layout to contain contents of main body of screen (drawer will slide over this) -->
<android.support.design.widget.CoordinatorLayout
android:id="@+id/content_frame"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
android:theme="@style/ThemeOverlay.AppCompat.ActionBar"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
/>
</android.support.design.widget.AppBarLayout>
<ListView
android:id="@+id/main_listview_timer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingTop="?android:attr/actionBarSize"/>
</android.support.design.widget.CoordinatorLayout>
<!-- Container for contents of drawer - use NavigationView to make configuration easier -->
<android.support.design.widget.NavigationView
android:id="@+id/main_nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:headerLayout="@layout/nav_header"
app:menu="@menu/drawer_view" >
</android.support.design.widget.NavigationView>
</android.support.v4.widget.DrawerLayout>
和我的label_btn.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<Space
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="10" />
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Button" />
</LinearLayout>