how to add actionbarsherlock menu to a fragment - android

I am using both actionbarsherlock and slidingmenu objects
the point is, I want my menu - which is sliding to do the following
push the currently visible screen aside, along with its actionbar
the fragment that is displayed inside the menu to have a different actionbar
how do i do that?
I've set everything to make 1 work
but the fragment is missing the menu - how to add it ?

You can't have multiple ActionBar in the same activity.
Best thing you could probably do, is not make the ActionBar slide with the menu, while starting/finishing an ActionMode when you open up/close the sliding menu.
Or if you really want to slide the ActionBar, then simply create a view in the menu fragment that will looks like an action bar.

You probably can use a custom layout in your actionbar and manipulate it by adding an animation so that it looks like the actionbar slides out and it is pushed by another actionbar when the menu slides in. The object would be the same, but the user perception will be of a sliding action bar pushing away the previous one.

Related

How to pairing bottom app bar with top app bar?

In the picture what I want to do.
I have two menu.xml files. How to add the first menu at top app bar and the second at the bottom app bar? Can I do this in one activity or I should create activity with top app bar + fragment with a bottom app bar? Thanks.
So, I solved this problem.
For toolbar on top of the activity I use setSupportActionBar() inflate menu in onCreateOptionsMenu() and processing MenuItem click in onOptionsItemSelected()
For BottomAppBar (new material component) I use bottomAppBar.replaceMenu() in order to set the menu. For processing MenuItem click: bottomAppBar.setOnMenuItemClickListener()
Result
How to add the first menu at top app bar and the second at bottom app
bar? Can I do this in one acivity or I should create Activity with top
app bar + fragment with bottom ap bar?
You'll probably be able to do that with onCreateOptionsMenu() for the top of the Activity, (called Toolbar) then use a NavigationDrawer and another View (Can be a custom view like LinearLayout with ImageViews or etc) or another Toolbar in the bottom.
Or, using custom view and inflating menus by onCreateOptionsMenu().
This might help for two Toolbars in one Activity: https://stackoverflow.com/a/37002188/4409113
Also: https://stackoverflow.com/a/34906999/4409113
In your case (as we can see in the picture), i believe there is a Toolbar at top of Activity, with CoordinatorLayout which has FloatingActionButton in the middle and there will be just inflating in java-kotlin side left.

Making ActionBar tabs appear under the content AND integrate a WebView in an ActionBar Menu

I'm currently working on an Android application with two ActionBar Tabs.
I have three questions:
1) How can I make the ActionBar Tabs to appear on the bottom of the app (under the fragments)
2) Can I make a WebView in a Navigation drawer (menu)
3) How can I let the ActionBar menu appear on the right side of the ActionBar?
Thanks for answering
EDIT:
With an ActionBar menu, I'm meaning the menu on the middle of this Picture:
http://static.androidnext.de/Facebook-for-Android.jpg
How can I make the ActionBar Tabs to appear on the bottom of the app (under the fragments)
Sorry, that is not possible with action bar tabs. You cannot even control if they show up as tabs at all, let alone their position.
Can I make a WebView in an ActionBar Menu (the menu for example Facebook has the main Navigation)
What you are referring to is a navigation drawer. Putting a WebView in a navigation drawer is technically possible but is unlikely to meet Google's design guidelines for navigation. In your case, given your third question, you presumably are not using this for navigation.
How can I let the ActionBar menu appear on the right side of the ActionBar?
That depends on what you are using for the navigation drawer. DrawerLayout supports this:
Drawer positioning and layout is controlled using the android:layout_gravity attribute on child views corresponding to which side of the view you want the drawer to emerge from: left or right. (Or start/end on platform versions that support layout direction.)

Using SlidingMenu with ABS Tabs working incorrectly?

I have Actionbar Sherlock and SlidingMenu set up in my project. I want the menu to slide in under the actionbar, so I set:
setSlidingActionBarEnabled(false);
Though, when I have the action bar Navigation Mode set up with tabs:
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
They stick with the action bar instead of sliding away. That causes the issue of being able to switch tabs and the view pager switching while the menu stays open. Along with it not being the aesthetic I am going for.
Is it possible for the tabs to slide away from the action bar with the menu? Or would it just be more practical to set up a custom implementation with radio buttons?
It's not possible to have the tabs slide when you are using NAVIGATION_MODE_TABS.
The alternative is to use the ViewPagerIndicator library and the TabPageIndicator mode from that. That way the tabs are a part of the activity layout, and will slide. The downside is that the tabs won't get embedded in the action bar on larger devices or when a device is in landscape.

Setting Navigation Icon on Android ActionBar

So I'm working on adding ActionBarSherlock and the Navigation Drawer to a project that previously implemented a custom (very poorly written) "action bar". Instead of using fragments and a backstack of activities for navigation, some activities show and hide different layouts. (That is, suppose I am in a list mode and then select a button to go into an edit screen. The app currently hides the list layout and shows another layout.).
So I've added actionbar sherlock and a navigation drawer to all the activities. I want to be able to programmatically switch the navigation icon from the 3 lines to the arrow when certain buttons are pressed.
I can't figure out how to do this though. Any ideas?
Thanks!
The solution to this problem is to use the method:
setDrawerIndicatorEnabled(boolean enable)
inside the ActionBarDrawerToggle class.
After:
drawer.setDrawerListener(toggle);
Use this code:
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setHomeButtonEnabled(true);
getSupportActionBar().setHomeAsUpIndicator(R.drawable.select);
It depends how wedded you are to built-in actionbar artifacts. You can always redraw the current actionbar by inflating a layout of your choosing, then calling
getSherlockActivity().getSupportActionBar().setDisplayShowTitleEnabled(false);
getSherlockActivity().getSupportActionBar().setDisplayShowHomeEnabled(false);
getSherlockActivity().getSupportActionBar().setDisplayShowCustomEnabled(true);
// Inflate and do whatever you need to your view...
getSherlockActivity().getSupportActionBar().setCustomView(abView);
getSherlockActivity().getSupportActionBar().show();
When you want to go back to your standard (assuming you're using a DrawerLayout to do your navigation drawer), you can just set make a call to setDisplayShowCustomEnabled(false) (re-enable showHome and showTitle as you please).
As far as I know, customization of the back button can only be done via themes. Besides, swapping the drawer icon for the back icon (within the same Activity) doesn't make sense, since users would still be able to access the navigation drawer by sliding the left most edge to the right. It just wouldn't make sense.
If you absolutely need the back icon, then it would make the most sense to make that screen a new Activity since you would indeed be adding another "level" to the stack, which is what the back icon represents.

android action bar with tabs below the screen

For my application , I'm planning to have a design as this:
http://img811.imageshack.us/img811/7045/problemel.png
-Design needs to have a title bar which is indeed the action bar in android. To overcome the compatibility issues, I used the sherlock action bar which is said to support older versions that dont have action bars. I havent tested yet for the older devices however.
-As far as I know, for navigation , we could rather use tabbed or dropdown list methods. I want to have constant tabs for every page in my app to stand below the page. This reflects the tabbed action bar, however I want it below not just under the action bar. I don't know how but youtube application somehow has it in the middle of the screen (if it's not a custom view). So how do we have tabs positioned in the bottom of the page?
-Also I want to have another menu, whose items depend on the page it's on. But the apperance will be the same for every page. In the picture on the left this menu has buttons as "Bt 1" ,"Bt 2". I dont want to repeat the same xml for every activity page, but I'm not sure how to achieve it without repeating. If the action bar allowed using both navigation tabs and the drop down list, I could put the items of this menu in the dropdown list just as the picture on the right (onto the gray button). But I guess it does not?!
Therefore I have to repeat the menu xml code in every page or is there another smart way?
Any advice will be appreciated.
This can be achieved not with tabs but by adding items to a linear_layout with a gravity of bottom but it is a bad practice as #D_Steve595 stated and should be avoided in android designs.
actionBar.setHomeButtonEnabled(false);
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
actionBar.setDisplayShowTitleEnabled(false);
actionBar.setDisplayShowHomeEnabled(false);

Categories

Resources