I'm trying to create some libraries which will help making the UI of your Apps compliant to the Android Design Guide.
Currently I take a look at the new NavigationDrawer introduced on Google I/O 2013. This library is very simple. You just have to initialize one instance of the NavigationDrawer object and then the Layout of the Activity is replaced with a special "Navigation Drawer" layout.
Now you can access a panel for the navigation sidebar with NavDrawer.NavigationPanel. Normally you should add a listview type view to this panel but you are totally free how you implement the contents. You can load a layout and add any objects you want to the navigation panel. In the example the mListView library from icefairy333 is used because I wanted to have the selected item sticky.
With NavDrawer.ContentPanel you get access to the content of your activity. Instead of adding views to the activity directly you should add all views to this panel.
There is a special SlideDrawable object in the NavigationDrawer library. This is a special drawable (I copied from v4 support library) used for the ActionBar icon animation.
Ok, the NavigationDrawer library was the easy part.
To get things right the navigation drawer has to interact with the ActionBar. I have written a small wrapper class for the ActionBar Class so that "home as up" and such things can be set. The big problem now is that I want to get an event if the home action item is pressed in the action bar. This is currently not possible in B4A I think.
That is because the menu system in B4A is very limited. Perhaps we can use this thread to discuss how to improve the menu system so that it is flexible and compatible to the current implementation.
Erel, have you ever thought about how to improve the menus? I think changing menu items is a must have feature in a future B4A version.
To compile the example you need the newest android.support.v4 library.
Currently I take a look at the new NavigationDrawer introduced on Google I/O 2013. This library is very simple. You just have to initialize one instance of the NavigationDrawer object and then the Layout of the Activity is replaced with a special "Navigation Drawer" layout.
Now you can access a panel for the navigation sidebar with NavDrawer.NavigationPanel. Normally you should add a listview type view to this panel but you are totally free how you implement the contents. You can load a layout and add any objects you want to the navigation panel. In the example the mListView library from icefairy333 is used because I wanted to have the selected item sticky.
With NavDrawer.ContentPanel you get access to the content of your activity. Instead of adding views to the activity directly you should add all views to this panel.
There is a special SlideDrawable object in the NavigationDrawer library. This is a special drawable (I copied from v4 support library) used for the ActionBar icon animation.
Ok, the NavigationDrawer library was the easy part.
To get things right the navigation drawer has to interact with the ActionBar. I have written a small wrapper class for the ActionBar Class so that "home as up" and such things can be set. The big problem now is that I want to get an event if the home action item is pressed in the action bar. This is currently not possible in B4A I think.
That is because the menu system in B4A is very limited. Perhaps we can use this thread to discuss how to improve the menu system so that it is flexible and compatible to the current implementation.
Erel, have you ever thought about how to improve the menus? I think changing menu items is a must have feature in a future B4A version.
To compile the example you need the newest android.support.v4 library.
Last edited: