I am creating an Android application with a bottom bar. I used an Android fragment to create the bottom bar and it is working well. Now I want to add some more activities to the application. The problem is I can't get my bottom bar fragment in the Activity. Is there any way to bring my fragment into an Android Activity? I tried this and a lot of other examples from the Google. Can anyone help me bring my fragments to an Activity?
Related
I watched some videos for navigation drawer in android studio .. some people started from an empty activity and other used Navigation Drawer Activity from the Starter ..
So what's the difference ?
And what activity i have to implement ?
(my first activity is splash screen and all others activity will be added as new activity, btw I'm doing a football application so advice me <3)
Android studio provides you some templates as starting point with boilerplate code to get you started quickly on your project.
If you select DrawerActivity, It will create one of the templates, you can use which has all the boilerplate implementation for the Drawer Menu.
On the other hand, if you select EmptyActivity, It will just an create an activity with nothing in it (mostly blank or HelloWorld TextView in it, depending on studio versions).
By the way, you can always create an EmptyActivity and add things gradually like drawermenu etc in it if you prefer this way.
Empty activity : It has just the white screen and nothing else.
NavigationDrawer activity : Empty screen integrated with Navigation Drawer
I have a problem...I am developing an app in android studio.In the meantime,there is already a navigation drawer in it.But the problem is, it only appears in the home screen.When it goes to another screen, the navigation drawer is not shown. I am new to android studio but i know some of Java languages.Can anyone help me with providing anything that would help me make the navigation drawer show in all of slides and pages in my app.
from docs
Navigation Drawer
The navigation drawer is a panel that displays the app’s main
navigation options on the left edge of the screen. It is hidden most
of the time, but is revealed when the user swipes a finger from the
left edge of the screen or, while at the top level of the app, the
user touches the app icon in the action bar.
for achieve what you asked you have to use Fragments
Fragment represents a behavior or a portion of user interface in an
Activity. You can combine multiple fragments in a single activity to
build a multi-pane UI and reuse a fragment in multiple activities. You
can think of a fragment as a modular section of an activity, which has
its own lifecycle, receives its own input events, and which you can
add or remove while the activity is running (sort of like a "sub
activity" that you can reuse in different activities).
see this examples for more details
1. Navigation Drawer - android hive
2. Navigation Drawer exp 2
3. Navigation Drawer exp 3
Refer this answer also
Answer
You have to add fragments in that activity where the navigation drawer exist. Whenver the user will click on the option in the navigation drawer the view should be changed by replacing with the required fragment.So by using the fragments user will stay on the same activity but just the views will be changed in that activity. you can refer to the fragments documentation provided by android developers. https://developer.android.com/guide/components/fragments.html
I've been trying to get back into something I was working on before and got stuck on. I found a picture on the google developers site that has what I'm trying to create.
https://material-design.storage.googleapis.com/publish/material_v_4/material_ext_publish/0B9PCOJnbdRP6QW9pN01mS2k4UFU/patterns_navigation_twolevel4.png
Basically, I have one activity, that has several fragments that you can navigate to through the navigation drawer that pulls out from the side. I'm trying to have one of those fragments be a fragment that has a tabbed layout, which works fine, except the tabs don't show up since the toolbar created in the activity. How do i do this?
I am developing an Android project with Android Studio.
I would like to have the menu is always accessible in every view like Google Play Store (the Sidebar) and App Store (the Bottom selection bar).
I am thinking to do it in two ways:
Make my app have only one activity with Navigation Drawer, all the other views are above this activity using fragments.
Recreate the sidebar or bottom selection bar every time I switch to another activity.
Both of these two ways are very complex and cost a lot. Do you have some better ways?
PS: If not, could you suggest me some links about how to implement these two methods?
Thanks a lot.
you can create a MasterActivity that extend Activity and contain your sidebar. other Activity can extend from your MasterActivity by this way you can access your sidebar on each activity.
I think you should use the default navigation drawer and default action bar.
If you are using the Android Studio then
right click on your package and go to New/Activity/Navigation Drawer Activity.
That will create navigation drawer fragment and activity automatically.
But If you are using Eclipse then these links will be useful for you.Navigation Drawer
Action Bar
you can use include tag in other layout activity and call Navigation Drawer:
<include
android:id="#+id/nDrawer"
layout="#layout/your_NavigationDrawerLayoutName"/>
I want to create a app with a menu at the bottom of the screen. This menu should be visible any time the app is started.
Im working with fragments, so the menu is one fragment.
So I have only one Activity as controller which loads different fragments above the menu fragment.
Because I want to create clean code, i dont know how to solve the problem that the Activity class is too big.
In other words, i want to create different controller within the same activity. How to do that?
Is there another approach to solve this issue?
You should be using the split action bar This allows you to put the Actions and overflow menu on the bottom of the screen. I believe you can use Action Bar Sherlock for backwards compatibility to older versions of Android. See their site for detail.
Another possibility is to look into using fragments with the ViewPager . Here is a library that works with compatability as well ViewPageIndicator . Here is a blog post , like I indicated in my comment I got this working with the tabs showing at the bottom and the pages above.