使用带有活动或碎片的导航抽屉? [英] Use navigation drawer with activities or fragments?

查看:93
本文介绍了使用带有活动或碎片的导航抽屉?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有侧边栏导航抽屉布局的Android应用,正在实现一个简单的SMS应用的功能.

I have Android app with sidebar nav drawer layout and I am implementing functionality of a simple SMS app.

我的问题是,如何在活动之间重用导航抽屉代码.每个示例都使用单击导航抽屉菜单中的项目后在某些主视图中显示的片段.如果我启动新活动并希望拥有与原始活动相同的侧边菜单怎么办?

My question is, how to reuse nav drawer code between activities. Every example uses Fragments that are displayed in some master view after item in nav drawer menu is clicked. What if I launch new activity and want to have the same side menu as the original one?

Google有官方建议如何实施吗?

Is there an official suggestion by Google how to implement this?

对我来说,问题是,要成为Android上的默认SMS应用,您必须进行一些特殊的活动来处理某些Intent.

The problem for me is that in order to be default SMS app on Android, you must have some special activities handling certain Intents.

我应该完全转储Activity并使用Fragment实现所有功能吗?

Should I dump Activities fully and implement everything using Fragments?

谢谢

推荐答案

Google的Android应用具有特定的架构,该架构包括以下内容:

Google's Android apps have a specific architecture which consists of the following:

  • 整个应用程序中通常只有一个 Activity ,如果需要更多活动,则它们都将扩展相同的 BaseActivity .
  • 不同的屏幕表示为单独的 Fragment .屏幕转换是通过片段事务在相同的 BaseActivity 中进行的.
  • There is often just a single Activity in the entire app, and if more activities are needed, then they all extend the same BaseActivity.
  • Different screens are represented as individual Fragments. Screen transitions take place through fragment transactions all within the same BaseActivity.

例如,仅

  • google/iosched .
  • 此项目中说明了将抽屉与不同屏幕集成在一起的方法,并在以下文章中对此进行了详细说明:

    The way to integrate the drawer with different screens is illustrated in this project, and further elaborated in the following articles:

    0. 指南到App Architecture

    1.. Android应用结构 .

    2..计划屏幕及其关系 .

    3..提供后代和横向导航 .

    4..提供祖先和时间导航 .

    5.. 模式–导航 .

    6.. 用户界面最佳做法 .

    采用这些(和其他)准则的应用程序的更多示例:

    More examples of apps that employ these (and other) guidelines:

    • Plaid
    • Elevate
    • Inbox by Gmail
    • Allo
    • Various Google apps such as Gmail and Play Store.

    这篇关于使用带有活动或碎片的导航抽屉?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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