I have a BottomNavigationBar in the MainActivity. I want to hide it in the some fragments.I saw this question but its solutions didn't work for me.How to hide bottom navigation bar in specific fragment?
I have three items with the following names.MainPageFragment and ListQuestionFragment and ListAnswerQuestion.ListQuestionFragment and ListAnswerQuestion contain the list of items and when User click every item a new fragment will be replaced.These fragments are the details of those item. I want to hide BottomNavigationBar in these fragments.
Related
Not sure if I'm fighting an uphill battle but I'm currently struggling with AppBar, Fragments and Bottom Navigation Bars.
I have a MainActivity that's a list view with an AppBar. It's created as a fragment with the intention to add another bottom navigation bar here in the future.
For now, when an item in the list is clicked it navigates to a detail view fragment. Here I still have the AppBar which is what I want however I would like to add a Bottom Navigation Bar. However when I navigate to the next fragment I lose my bottom navigation bar.
Is there a way to keep maintain Bottom Navigation Bars within Fragments? I tried breaking them out into activities but discovered then I lose my AppBar.
Is what I'm doing above feasible in Android?
Ideally I'd like this:
Do you have different nav graphs for different fragments? You need to have the detail view fragment in the same nav graph as the bottom navigation view. You don't need to have another item in bottom navigation but declare fragments that you want with bottom navigation in the same nav graph.
I've created a NavControllerActivity, which is based on UINavigationController from iOS. I would like the app bar's menu items to only show the menu items for the currently displayed Fragment.
At the moment, as each new Fragment is pushed onto the nav stack, the menu items just get appended to the existing ones. When I tap Back and pop the Fragments off of the nav stack, then those menu items disappear as one would expect.
However, I'd like to hide/remove/something the existing menu items when the new Fragment is pushed on and show just the menu items for that Fragment. Then when that Fragment is popped off, I'd like to remove its menu items and reinstate the menu items from the Fragment that is now at the top of the stack.
I'm currently having each Fragment generate the menu items in onCreateOptionsMenu().
Is there a way to make Android only show the menu items for the top level fragment in my Activity?
Edit: Do I need to have the Activity directly manage the menu items instead? Essentially be constantly invalidating and replacing the menus whenever I push/pop a Fragment? i.e. Still have the menus really defined and controlled within the Fragment, but have the enclosing Activity passing along the menu creation calls to the Fragment at the top of the stack?
I am using a NavigationDrawer in my application and I am loading in the drawer a ListView. When the drawer is opened, it covers almost half of an Activity which contains also a ListView.
The problem that I face is that if I tap on the drawer(not on an item contained in the drawer), a ListView item from my Activity gets the click event and then starts an activity associated with that list item.
Is it possible to restrict the clickable area of the drawer only to the list items?
I assume your drawer layout is more complex than just a simple ListView, if you have place to tap on the drawer.
In that case, you could simple specify
android:clickable="true" for your top drawer layout (LinearLayout, RelativeLayout or whatever you use).
In my app navigation drawer and viewpager are on same activity. I want to hide viewpager on clicking the item on navigation drawer.
I tried to set its visibility as GONE but it didn't work.
Pleaseeee tell me how to hide it thanks..
Tab.setVisibility(ViewPager.GONE); this is the line I wrote in my code
On clicking drawer item fragment containing webview opens
If you want to hide the ViewPager, you need to set it's visibility to View.GONE. Try
myViewPager.setVisibility(View.GONE);
instead. Currently you're setting the visibility on a Tab and not the ViewPager itself. They're 2 completely different things.
Inside my app I am using navigation drawer for my navigation. For each "page" I am using fragments (like showed here: http://developer.android.com/training/implementing-navigation/nav-drawer.html). It works completely fine, but now I want to create swipe tabs. I want to display those tabs only on one of the fragments. Problem is, that tabs are displayed on all fragments, which is ofcourse perfectly normal because tabs are inside action bar. What should I do, to display tabs only on one fragment?
From what I have understood, you are interested in showing action bar only in a particular fragment (not visible when swiping in subsequent fragments). The best way would be to code the action bar in fragment instead of using the action bar in main fragment and then creating swipe views (or sub fragments).
Hope it helps.