create app with menu at the bottom (like many iphone apps), how to organize activity / fragments - android

I want to create a app with a menu at the bottom of the screen. This menu should be visible any time the app is started.
Im working with fragments, so the menu is one fragment.
So I have only one Activity as controller which loads different fragments above the menu fragment.
Because I want to create clean code, i dont know how to solve the problem that the Activity class is too big.
In other words, i want to create different controller within the same activity. How to do that?
Is there another approach to solve this issue?

You should be using the split action bar This allows you to put the Actions and overflow menu on the bottom of the screen. I believe you can use Action Bar Sherlock for backwards compatibility to older versions of Android. See their site for detail.
Another possibility is to look into using fragments with the ViewPager . Here is a library that works with compatability as well ViewPageIndicator . Here is a blog post , like I indicated in my comment I got this working with the tabs showing at the bottom and the pages above.

Related

Android Airbnb like Tabs

I am trying to figure out how airbnb has implemented its Tab Bar, it either seems they have hidden their actionbar and everything has been shifted onto a tab bar but then the right most user icon opens the navigation drawer which should be ideally on actionbar, Or everything is on action bar itself but then how can those 3 tabs/icons on left be implemented on actionbar. (Kindly refer attached image)
Can somebody put some light on how this can be implemented. How to go about it? Also are those 3 icons fragments or separate activities?
Here, is a library which makes your life simpler to implement TabBarView for actionbar tabs.
https://github.com/Mirkoddd/TabBarView
This should give you insight about how to use it for your app.

How to make the Navigation Drawer or bottom selection bar always accessible in an android project?

I am developing an Android project with Android Studio.
I would like to have the menu is always accessible in every view like Google Play Store (the Sidebar) and App Store (the Bottom selection bar).
I am thinking to do it in two ways:
Make my app have only one activity with Navigation Drawer, all the other views are above this activity using fragments.
Recreate the sidebar or bottom selection bar every time I switch to another activity.
Both of these two ways are very complex and cost a lot. Do you have some better ways?
PS: If not, could you suggest me some links about how to implement these two methods?
Thanks a lot.
you can create a MasterActivity that extend Activity and contain your sidebar. other Activity can extend from your MasterActivity by this way you can access your sidebar on each activity.
I think you should use the default navigation drawer and default action bar.
If you are using the Android Studio then
right click on your package and go to New/Activity/Navigation Drawer Activity.
That will create navigation drawer fragment and activity automatically.
But If you are using Eclipse then these links will be useful for you.Navigation Drawer
Action Bar
you can use include tag in other layout activity and call Navigation Drawer:
<include
android:id="#+id/nDrawer"
layout="#layout/your_NavigationDrawerLayoutName"/>

Implementing Navigation Drawer in android using different ways

I am working on an application, in which I need to implement navigation drawer. We have two different ways of implement navigation drawer in android as shown in attached screen shots :
In first way the sliding list is over main content. In second type, sliding list becomes visible and make main content to slide left to right with Navigation Drawer list.
I goggled a lot about this and only got solution of first type. I want to implement Navigation drawer like second type in attached screenshot. So please tell me what changes I need to make.
Thanks.
For the first case google's official Navigation Drawer is there.
And for the second case there's a third party library on github.
here's the link: https://github.com/jfeinstein10/SlidingMenu
Also I feel you've to use ActionBarSherlock (again a third party library) in order to implement the second case.
Moreover the google's drawer method is the recommended one as it supports a stable action bar, from where you can choose items even when the drawer is open. Also the design + app flow is slick and faster in this case as compared to the third party lib.

Activity/Fragments & Action Bar

I'm really new to Android and I want to implement listview and tab action bar:
Home page:
A list that has action bar on top with two tabs (swipe left/right).
The items in the list are clickable.
Detail page:
One of the tab will just have some content
The other is another list with unclickable items
What should I use?
A listview activity or a listview fragment for the home page?
Or does anyone know of an example that is similar to this?
I don't care about backwards compatibility (for now)
Thanks in advance!!
I think this Android Developers' tutorial is pretty self explanatory. You should be able to figure it out from that.
I'd suggest you go with fragments as they're the newest way; whereas activities are getting old now. This will make it easier for your application to accommodate future Android updates.
This may also help you out regarding Fragments.

How to structure code for Activitys in a tabhost and actionbars

I want to have a few pages under a tabhost. The pages with the tabs, are accessed on about page 2/3 after application start. I am confused in how to link to the first page of the tabhost (from a page without a tabhost)
Each tab in the tabhost is a separate activity.
So when it's time to send user to a page in the tabhost, do I start the Tabhost activity (from extends TabActivity), create the tabhost, then... somehow choose which page in the tab to load? like tabhost.myTab.trigger.start(); INSTEAD of just loading one of the tabs activities directly..
So therefore anytime you leave the tabhost, and come back to it , you are recreating it, is this the correct way to structure things?
Thanks!
The TabHost method is considered a pretty old way of creating tabs within your Android application. This is especially so if you're placing Activities within those tabs.
A modern Android application uses Fragments, and uses the Action Bar framework to place those Fragments within tabs.
This can be done easily from your main Activity by using
getActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
This has several advantages. It means your Fragments can be placed inside of a ViewPager (so the user can swipe between them). It also means that your tabs will adapt to the device they're running on. (On a phone they may appear below the Action Bar, but on a tablet they actually become part of the Action Bar).
Depending on your implementation, this can be done is such a way that navigating between tabs does not cause the Fragments to be recreated (if that's what you're after).
A detailed guide on how to implement Action Bar Tabs can be found here
If backwards compatibility is a concern, then check out the amazing Action Bar Sherlock library.
I don't fully understand the behavior you are trying to accomplish.
Though, if you don't want to reinvent the wheel, i would recommend you to install the ActionBarSherlock demo apps1 to check if the desired behavior is already implemented as one of the library examples. If it's already done, then you can go to the github project to take a look at the source code, learn how it's done, and contribute with it.
Action Bar Sherlock demos
https://play.google.com/store/apps/details?id=com.actionbarsherlock.sample.demos&hl=en
Action Bar Sherlock Fragment demos
https://play.google.com/store/apps/details?id=com.actionbarsherlock.sample.fragments&hl=en

Categories

Resources