使用ViewPager与抽屉式导航操作栏标签 [英] Action Bar Tabs using ViewPager with Navigation Drawer

查看:213
本文介绍了使用ViewPager与抽屉式导航操作栏标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

要求: - 操作栏标签使用ViewPager与抽屉式导航

Requirement:- Action Bar Tabs using ViewPager with Navigation Drawer .

我可以创建一个导航抽屉的例子

I can create a Navigation Drawer example

操作栏标签单独使用ViewPager。

Action Bar Tabs using ViewPager separately.

但是当我尝试一次我有问题,同时使​​用。

But when I try to use both at once I am having issue.

我可以创建导航抽屉使用的片段,用片段操作栏选​​项卡。但是的两个例子中,初始活性是片段活性的影响。

I can create Navigation Drawer using fragments and Action Bar Tabs using Fragment. But the initial Activity of the both examples is Fragment Activity.

如何实施操作栏选项卡上的片段是抽屉式导航栏的一部分?

How to implement the action bar tabs on a fragment which is part of the navigation drawer?

推荐答案

使用以下布局的主要活动。

Use the following layout for your main activity.

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <android.support.v4.view.ViewPager
        android:id="@+id/viewpager_container"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:background="#ffe6e1d4"
        android:focusable="true"
        android:focusableInTouchMode="true" />    

    <ListView
        android:id="@+id/left_drawer"
        android:layout_width="240dp"
        android:layout_height="match_parent"
        android:layout_gravity="left"
        android:listSelector="@drawable/drawer_list_selector"        
        android:background="@color/drawer_bg" />

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

写您的FragmentPagerAdapter作为展示在 APPTabsAdapter

这是我是如何建立它在我的项目之一。

This is how I had built it in one of my projects.

您可以尝试和寻求帮助,如果需要的话。

You can try and ask for help, if needed.

您可以在此 GitHub的回购需要帮助

感谢。

这篇关于使用ViewPager与抽屉式导航操作栏标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆