简体   繁体   English

在活动上实施导航抽屉

[英]Implement Navigation Drawer on Activity

I've created a Navigation Drawer in Android Studio with : File > New > Activity > Navigation Drawer Activity. 我已经在Android Studio中使用以下文件创建了导航抽屉:文件>新建>活动>导航抽屉活动。 It work very good, but how I can add this Navigation Drawer in my mainactivity or in other activity? 它工作得很好,但是如何在我的mainactivity或其他活动中添加此导航抽屉? Because it's a problem, It's two different activity... Sorry for my English i'm French :( 因为这是一个问题,所以这是两个不同的活动...对不起,我的英语是法语:(

Navigation Drawer activity template has only one activity, If you want to use this template then that activity should be your main activity. Navigation Drawer activity模板只有一个活动,如果要使用此模板,则该活动应该是您的主要活动。

I mean simply move your old main activity 's code to the Navigation Drawer's activity which created with the template and make it your new App's main activity! 我的意思是将您的main activity的旧代码简单地移动到使用模板创建的导航抽屉活动中,并将其作为新应用程序的主要活动!

Otherwise, you will have to implement The navigation drawer in your old main activity just like the template does 否则,您将必须在旧的main activity实现导航抽屉,就像模板一样

== ==

Update : 更新

The Navigation Drawer activity template has 4 different xml layouts which usually named: Navigation Drawer activity模板具有4种不同的xml布局,通常被命名为:

1- activity_main.xml contains the DrawerLayout and includes no. 1- activity_main.xml包含DrawerLayout ,不包含。 2 2

2- app_bar_main.xml contains the action bar xml code and includes no. 2- app_bar_main.xml包含操作栏xml代码,但不包含。 3 3

3- content_main.xml this should be your main layout 3- content_main.xml 这应该是您的主要布局

4- nav_header_main contains the top view of the drawer 4- nav_header_main包含抽屉的顶视图

Note: names might be different depending on the Drawer's activity name. 注意:名称可能会有所不同,具体取决于抽屉的活动名称。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM