I am developing an application that contains many activities and i created my own menu (i don't want to use the built in menu button) with the Sliding Drawer as the sliding drawer is at the bottom of the screen and contains my menu buttons
what i need is to make that sliding drawer to appear in all my activities
i tried to create an activity and set it's content view to the xml file that includes the drawer and then extends that activity in all other activities but this solution doesn't work
so any suggestions ?
I know this is two years late but for those who would like an answer here it is. Mr Orlov had an appropriate response, just a few adjustments needed.
ALSO: If you want your sliding drawer to appear on top of your layout (duh!) then place the frameLayout that is after the slidingDrawer before the slidingDrawer.
Finally after 3 years, here's the complete solution to this important question for whom may have not been completely guided by Mr. Orlov's answer.
His method for making a hierarchy view was completely OK but there was some small mistakes that may mislead beginner developers.
So the 100% working soloution would be like this :
activity_drawer.xml
DrawerActivity.java
MainActivity.java
Don't forget to declare DrawerActivity in manifest.
Hope it helped.
Extending is the right way. Just override setContentView in the right way. Here's the working example, but instead of drawer, I use a created a custom tabbar:
Define a layout with your drawer like this:
this is
act_layout.xml
This will be your base layout to contain all other layouts in the act_content frame. Next, create a base activity class, and do the following:
What we do, is basically intercept all calls to setContentView(int resId), inflate our layout for drawer from xml, inflate our layout for activity (by reId provided in method call), combine them as we need, and set as the contentView of the activity.
EDIT: After you've created the stuff above, just proceed to write an app as usual, create layouts (without any mention of a drawer) create activities, but instead of extending simple activity, extend DrawerActivity, like so:
What happens, is that setContentView(R.layout.some_layout) is intercepted. Your DrawerActivity loads the layout you provided from xml, loads a standart layout for your drawer, combines them and then sets it as contentView for the activity.