简体   繁体   English

如何将我现有的 Android Studio 的两个活动转换为两个片段,以便我可以制作导航栏?

[英]How do I convert my existing two Activities of Android Studio into two fragments so that I can make the Navigation Bar?

I'm new in Android Studio and I've been mostly learning through experimenting so it would be really appreciated if you could explain all the steps please.我是 Android Studio 的新手,我主要通过实验学习,所以如果您能解释所有步骤,将不胜感激。

I already have an app complete which has two Activities which are connected to each other.我已经有一个完整的应用程序,它有两个相互连接的活动。 I made this in an Empty Activity.我在一个空活动中做了这个。 Now I want to this to have an Navigation Bar, what do I do?现在我想要这个有一个导航栏,我该怎么办?

I tried making a new Navigation Bar Activity and tried to copy paste everything, it worked for the layout file with the xml file but I can't where I should be putting in my code?我尝试制作一个新的导航栏活动并尝试复制粘贴所有内容,它适用于带有 xml 文件的布局文件,但我无法将我的代码放在哪里? I searched up numerous posts to no avail.我搜索了很多帖子都无济于事。 My original code had over 300 lines so I really can't write it all over again.我的原始代码有 300 多行,所以我真的不能重新写一遍。 Can someone please help me out?有人可以帮我吗?

I'm doing this app in Java.我在 Java 中做这个应用程序。

You'll need to use just one main activity and convert the current activities to Fragments.您只需使用一项主要活动并将当前活动转换为片段。 So if you've not heard of Fragments see here https://www.google.com/url?sa=t&source=web&rct=j&url=https://developer.android.com/guide/fragments&ved=2ahUKEwj7wpaxxJnvAhXCx4UKHf9tAqQQFnoECAMQAg&usg=AOvVaw13OtAaEKbecXytTb4qLxel So if you've not heard of Fragments see here https://www.google.com/url?sa=t&source=web&rct=j&url=https://developer.android.com/guide/fragments&ved=2ahUKEwj7wpaxxJnvAhXCx4UKHf9tAqQQFnoECAMQAg&usg=AOvVaw13OtAaEKbecXytTb4qLxel

Then you can place a navigation bar widget on the main activity, this can be configured to the amount of fragments you need.然后您可以在主活动上放置一个导航栏小部件,这可以配置为您需要的片段数量。

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

相关问题 我如何将两个活动从我的代码转换为两个片段 - How do i convert the two activities from my code to two Fragments 如何在android studio中一次搜索属于不同活动的两个不同列表? - How can I make a single search for two different lists belonging to different activities in android studio? 我如何使用引用片段和活动的底部导航视图? - How can i use bottom navigation view referring to fragments and activities? 如何在 android 工作室的两个活动中同时动态创建 TextView? - How can I create dynamically a TextView simultaneously in two activities in android studio? 如何在一个文件中创建两个活动? - How can i make two activities to one file? 如何清除Android中除前两个活动之外的所有活动? - How can I clear all but the top two activities in Android? Android:如何将活动转换为片段以正确使用导航抽屉? - Android: how to convert activities to fragments in order to use the navigation drawer correctly? 我如何做到这一点,所以nextLine等于数组中的两个字符串 - how do i make it so nextLine equals two strings in an array 如何重写我的两个方法,以免出现 NullPointerException? - How to rewrite my two methods so I do not get a NullPointerException? 如何在Android中的两个片段活动之间切换 - How to shift between two fragments activities each other in android
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM