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?
Related
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 interested in material design and wanted to build a layout for the main page of my app so that it looks like the default template for Scrolling Activity but also has a Navigation Drawer like the default template for Navigation Drawer Activity for easy navigation.
As an example, Google's Play Music app already does this sort of thing.
Have a look:
Scrolling list with a banner and a FAB at the top,
Navigation Drawer, accessed by swiping from over to the left
I've searched everywhere and could find a direct way for implementing such a layout. So I tried doing it on my own and with some changes here and there in the default templates of Scrolling Activity and the Navigation Drawer Activity I was able to achieve something along those lines but not exactly what I was looking for.
I was hopping if someone could present a better way of doing it.
You can still use the DrawerLayout supplied in the Android support library with a FrameLayout and ListView to achieve the Navigation drawer. In the FrameLayout, you will display a Fragment which takes a ScrollView to display scrollable content. The Fragment can also have other widgets that let you customize your layout.
I've got exactly what I wanted, you simply need to include Scrolling Activity's layout inside the layout of Navigation Drawer Activity and it works nicely.
You can use the default templates for these activities given in the Android Studio to save yourself some time or start from scratch.
Let me know if anyone needs some code and I will be more than happy to post it :)
I am developing an application which has a navigation drawer with 9 fragments.
Two of nine fragments have tabs(4) interface implemented. Each tab has its own menu option and each fragments (other than with tabs) have their own menu options.
Now the issue is,
When i access or switch a simple fragment(without tabs) from the navigation drawer then its menu options and working fine.
BUT
When switching from a tabbed fragment after accessing , its menu options now appear on every other fragment in the navigation menu.
For example
I access and switch from fragment "A" ->everything goody including all menu options
I access and switch from fragment "B" (with tabs) then all the other fragments have its menu options.
If I didn't explain my problem effectively then do ask me again in the comments. I have been stuck with this problem since a week. Maybe a small problem or something else but do need some help from the people here.
////update//
SetHasMenuOptions implemented in each fragment. All fragments working fine except the tabbed ones
The main problem is, after accessing tabbed fragments all the menu options of other fragments are replaced by the tabbed menu options.
3 posting a question through my phone cant post code sample.
Actually first i had problems like this with every fragment but then i implemented sethasmenuoptions
And menu.clear() in each fragment and every fragment seems to work
Like it should except the tabbed ones
Hope this info helps
Thanks
Use transaction.addToBackStack(null) while fragment transaction and in layout set background colour to the fragments .
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?
I got a navigation drawer on the activity of my app, but once I get the fragment parts of my app running (through a fragmentActivity) I have trouble programming a navigation process over there. I want my users to be able to navigate from one fragment to another fragment using the navigation drawer, making life easier.
Does anyone have a solution to this?
I think what you want is a ViewPagerIndicator, and to use a ViewPager with a FragmentPagerAdapter to page your Fragments.