【发布时间】:2017-12-24 07:22:39
【问题描述】:
我在我的应用中创建了侧边栏导航。现在我想在上面创建一个点击事件。
我已经搜索过它并获得了文档,但我无法理解。
所以请任何人都可以提出更好的来源,因为它会有所帮助。 youtube 上的教程会很有帮助。
我的导航菜单
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/nav_account"
android:icon="@mipmap/ic_person_black_24dp"
android:title="My Account"/>
<item android:id="@+id/nav_setting"
android:icon="@mipmap/ic_settings_black_24dp"
android:title="Settings"/>
<item android:id="@+id/nav_logout"
android:icon="@mipmap/ic_logout_black_24dp"
android:title="Logout"/>
</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"
tools:context="com.example.lenovo.jdstudio.MainActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<include
layout="@layout/navigation_action"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/textView2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Main Layout"
android:textAlignment="center"
android:textSize="24dp" />
</LinearLayout>
<android.support.design.widget.NavigationView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
app:headerLayout="@layout/navigation_header"
app:menu="@menu/navigation_menu">
</android.support.design.widget.NavigationView>
</android.support.v4.widget.DrawerLayout>
【问题讨论】:
-
在此处发布您的代码导航抽屉代码
标签: android android-fragments navigation-drawer