Android 4.2 : Main Activity actionbar hides launching the new activity - android

I am developing an android application, where in MainActivity i am creating the actionbar with tabs for the application. i do have set listener for Tab click of actionbar which launches new activity in the application...till this everything is working fine.
Problem is : When new activity get created on Tab click, ActionBar of the application (which is created in main activity) is not shown....it shows application icon and name but NO TABS which i created in Main Activity.
I am no using any supported libraries to support previous versions of android. I am using Android 4.2.
Thanks in advance.

A solution can be to extend the onCreateOptionMenu method as shown here.
This provides somewhat guidance on a possible solution, using fragments instead of activities.

I think the first answer to this question might help you:
Android - Switch Tabs from within an Activity within a tab
Particularly the links to the example source code

Related

Actionbarsherlock use activities or fragments

I've been working on a school project in a course for Mobile prototype for a couple of weeks when our mentor said we should change our way of navigate in the app.
Before the app started with a simple menu where the user could chose which feature to open, which could be different activities, listactivities, mapactivities, activities with custom views, ect.
We then found the ActionBarSherlock library which could help us make a nice tab bar. But should we then change our activities to be fragments (supportfragments runs 2.3.3) or can we keep it as (normal) activities? if so how to best show this under each tab.
Actionbarsherlock have been implemented successfully in our apps start activity and now we "only" need to make the navigation to the existing the activities or change them to fragments.
Do tell if this isn't clear what have described or you need any further information.
If you wish you can only use Activities with ActionBarSherlock
It all depends on what your want to achieve and the use of fragment might help you making a cleaner app.
Actionbarsherlock sample:
1° tab bar with fragment & viewpager
2° tab bar with fragment

TabHost with different activities

I'm trying to implement an activity which will include TabHost and each tab in it will run\represent a different Activity so if the user press on tab #1 he'll see Activity A and if he'll press on tab #2 he'll see Activity B.
I don't want to use TabActivity as it been deprecated but the new API FragmentTabHost just doesn't seem to be the right answer\implementation (i need to support OS 2.2 and later).
Does anyone have a good idea\example how to do it?
Thx
Don't use TabHost anymore. Use the new ActionBar API with ActionBarSherlock.
To support Fragments down to Android 2.2 you have to use the Android Support Library.

Android ICS Tutorials & Tabs

so I wanted to implement tab views on my app.
But I realised the google tutorial on tab views is broken and TabActivity is deprecated.
I tried inserting the tabhost element through the Graphical Layout but it won't even show up when my app starts.
It's just a blank screen.
What am I supposed to do/look for? I'm kind of lost here.
Thank you for any help/input.
As you can see from its docs, TabActivity has been replaced with Fragments. Here's a sample project.

Is it possible to show tab host on overall application in android

Can I implement a tab host which will remain in overall application and works through out the application .
and
Also can i implement the tab host on the top and on the bottom of the same activity.
Any tutorial any help please....
Thanks
This is possible if you use Activity Group. But still it is deprecated and hence you cannot use it for newer versions of android. But still, you can go through what it is and try to implement it.
ActivityGroup Example
http://blog.henriklarsentoft.com/2010/07/android-tabactivity-nested-activities/
http://gamma-point.com/content/android-how-have-multiple-activities-under-single-tab-tabactivity
So now since Activity Groups are deprecated what is the alternate strategy we can make use of? Here is the solution for this problem.
Go for fragments or Views.
I have pasted the comment which I recieved from Commonsware regarding the ActivityGroup.
You never needed ActivityGroup to use tabs. You can put views in tabs, for example (github.com/commonsguy/cw-android/tree/master/Fancy/Tab). Going forward, tabs are in the action bar on Honeycomb, typically using fragments. You can achieve the same functionality on previous versions of Android using ActionBarSherlock.

Use tabs in Actionbar to launch activities

I have an Android application for pre-Honeycomb devices that uses custom tabs to launch various activities in the app. I'm using Android Compatibility Library and each activity contains one fragment.
I want to develop the app for Honeycomb devices also and I would like to use the tabs in the actionbar for version >= 11 instead of the custom tabs that i use in versions < 11.
My first question is if it is possible to use the tabs in the actionbar for launching activities and if yes, how? I see from the documentation that the main purpose of the tabs is to show/hide fragments and not entire activities.
What other solutions do I have?
EDIT:
I can see that I can call other activities from my implementation of ActionBar.TabListener so I think this would work. Is there a possible problem with this approach?
Yes, it is possible to launch activities from tabs. However, it's a bit tricky because some of the TabListener callbacks are called even when creating the tabs for the first time.

Categories

Resources