Android Studio 有这些空白活动导航示例 - Swipe Views (ViewPager) 和 Navigation Drawer。
我的目标是制作一个具有这两种导航类型的应用程序来遍历数据集合。
例子
所需行为的最基本示例是包含 15 篇文章的应用程序。当应用程序打开时,用户会看到第一篇文章。然后用户可以打开导航抽屉并选择文章或使用滑动转到下一篇文章。
欢迎任何想法或示例。
背景
我正在为 Android 4.0+ 构建应用程序
Android Studio 有这些空白活动导航示例 - Swipe Views (ViewPager) 和 Navigation Drawer。
我的目标是制作一个具有这两种导航类型的应用程序来遍历数据集合。
例子
所需行为的最基本示例是包含 15 篇文章的应用程序。当应用程序打开时,用户会看到第一篇文章。然后用户可以打开导航抽屉并选择文章或使用滑动转到下一篇文章。
欢迎任何想法或示例。
背景
我正在为 Android 4.0+ 构建应用程序
You've already mentioned both of the necessary widgets. Implement a NavigationDrawer
, and use a ViewPager
as the main content view as described in the NavigationDrawer
documentation.
Edit:
Set your content view using an XML similar to the following:
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.support.v4.view.ViewPager
android:id="@+id/tutorial_pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentTop="true" />
<ListView
android:id="@+id/app_drawer_left"
android:layout_width="@dimen/navigation_drawer_width"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="@color/off_white"
android:choiceMode="singleChoice"
android:divider="@drawable/horizontal_divider_dashed"
android:dividerHeight="1dip" />
</android.support.v4.widget.DrawerLayout>
Then just set up your activity as you would when using a ViewPager/ListView.