I've done a great amount of searching and I can't seem to find anything that helps me. I'm new to Android programming (I do know Java though), and I am working on an app that deals with dynamic content being downloaded from a server. I would like to have a bottom navigation bar, that is persistent throughout the app. This nav bar will consist of 5 buttons, that when clicked will open a new activity. However I would like the activity to be loaded in the content area above the nav bar.
So basically I will have a layout that contains a content view and the nav controller. The nav controller should never change...the content view should load a new activity upon nav button click. Does anyone have any ideas? Thanks.
You will have to create a common layout for the navigation bar , and include it in every layout of the activity. use "include" tag in the xml to do this. please have a look at the discussion below, it may help you.
Common buttons or tabs at bottom for every activity
Have a look at this project: http://code.google.com/p/androidtabs/
You might want to consider looking at Fragments since the TabActivity is deprecated. You would need to download a compatibility package in the SDK in order to use it on pre-honeycomb devices. It should be able to do exactly as you want.
Related
I am using ActionBar with ViewPagerIndicator or ActionBarTabs. It's consume quite space. I have created a custom layout for action bar,but it didnot work well for tabs.. I need some thing look like below image
I guess there might me some logical errors in your code.There are two concept in what you are trying to do, first is you need to know how to work with Action bar(http://www.androidhive.info/2013/11/android-working-with-action-bar/) and second is working with Tab layout with swipeable views (http://www.androidhive.info/2013/11/android-working-with-action-bar/).After learning the two concept try to sync it then you will get the desired result.
Let me try to make my question much clearer here. Supposed I have a custom tab created by using buttons and images in XML layout and it looks like this.
Each of these buttons, should call a class. Normally, Intent is used to call new class when onClick. But the whole layout would be redrawn when I call any of the classes via Intent.
Intent intent1 = new Intent(TabBar.this, Favourites.class);
startActivity(intent1);
I tried using TabHost and it worked, but my project requires me to use a custom tab bar.
I also tried the solution to this Dynamically change view inside view in Android, which is similar to what I wanted, (switching layouts and maintaining the tab bar below it), which worked as well.
My goal is to maintain the custom tab that I have, and change the classes instead of layout without redrawing the custom tab bar everytime I click on every buttons. With classes, I can run different functions and call different activities.
I googled a lot on this but couldn't seem to find a solution or reference. Can somebody guide me? Thanks in advance.
Update :
I'm new in Android, and after attempting many times, I decided to try out codes from AdilSoomro to achieve what I wanted, http://adilsoomro.blogspot.com/2011/06/iphone-like-tabs-in-android.html which is to create custom tabs that looks like iPhone tabs. However, this project uses TabActivity that is now deprecated in Android 4.1. I attempted to change it to FragmentActivity after referring to other sources that uses Fragments for tabs.
http://android.codeandmagic.org/2011/07/android-tabs-with-fragments/
http://thepseudocoder.wordpress.com/2011/10/04/android-tabs-the-fragment-way/
I managed to create it using FragmentActivity and here is where you can refer to them :
How to use custom iPhone tab in FragmentActivity?
You can use TabHost control to achieve this. Go through this post
It explains all the possibilities. It also includes using custom tab bar defined in the xml file.
One of the way to achieve this is create footer and use it in all your activity. Like This. And Let me know its useful as per your requirement or not.
I am in the process of replacing the Android Popup Menu with a Solid bar containing the buttons at the top of the screen. Now diffident activities contain the same buttons , plus to enhance the user experience we are keeping the Menu Bar with the button. Now i want to make this generic enough. Does anyone know of any good UI Patterns that will help me achieve this. I dont want to copy and paste my layouts xml code, plus the onClick listeners have the same code across the activities. Any help will be appreciated.
Kind Regards,
Mateen.
Use the ActionBar and the Compatibility Package.
If you have seen the skype android app, then you may have noticed that when skype moves from one activity to another, the top bar remains in place while the rest of the page slides out and the new activity comes in.
So how are they doing it? I want to do something like that.
Fragments can do what you wan't, and a lot more
In skype.. They are using Tab Activity...
Refer : http://developer.android.com/reference/android/app/TabActivity.html
Android TabHost Tutorial
Also if you want to use a single title through out the applciation :
You can define a title_layout.xml... & include it in the top of all your layouts like
<include layout="#layout/title_header"/>
You need to create a custom view which will act as your Tab Bar.
After creating your custom tab bar use it in whatever activity as you want.
Check this for more info on custom views.
http://developer.android.com/guide/topics/ui/custom-components.html
I actually want to apply a custom title bar (kind of like the Action Bar), but since i'm developing for Froyo, I actually need to have it in a xml file. The trivial way to do this is to just write the code to create the title bar in each of the activities.
I did search around for some efficient ways and found this on SO
Similar Problem
There are 2 solutions proposed over there, but I am having problems in implementing them.
To include the layout of your title bar in the layout of all the Activities. My question is say I have a sample layout as follows, where should the include tag go and do I need to use Theme.NoTitleBar theme for the application in order to get it working?
To subclass Activity and then derive all of my Activities from that. Should the custom Title bar creation method be defined in the onCreate method of the subclassed Activity. Because if I do this, the custom title bar does appear, but it appears blank. No buttons,etc.. are present on it.
Thanks in advance for any help you provide
The tag belongs inside the top level view container (linear layout/relative layout). Yes use NoTitleBar so you don't have the Android provided title bar in your app window.
There is obviously an issue with your code there, with out any code in your post I cannot help you.