【发布时间】:2016-02-07 09:14:48
【问题描述】:
我需要创建一个导航抽屉,例如 Flipkart 或 Astro 文件管理器应用程序。 如何将 listView 替换为可展开的 listView?
我需要一个这样的导航抽屉:
这是我的xml:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
tools:context=".MainActivity">
<include
layout="@layout/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<!-- This DrawerLayout has two children at the root -->
<android.support.v4.widget.DrawerLayout
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- This LinearLayout represents the contents of the screen -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<!-- The main content view where fragments are loaded -->
<FrameLayout
android:id="@+id/flContent"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</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/nvView"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="@android:color/white"
app:headerLayout="@layout/nav_header"
android:choiceMode="singleChoice"
app:menu="@menu/drawer_view" />
</android.support.v4.widget.DrawerLayout>
【问题讨论】:
-
请告诉我们你到目前为止做了什么。
-
我刚刚创建了一个普通的导航抽屉,带有一个列表视图
-
你是一个可扩展的列表视图,而不是你的好去处
标签: android navigation-drawer expandablelistview