Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9115679
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T04:29:20+00:00 2026-06-17T04:29:20+00:00

Hi i need to implement ActionBar in my application, but i haven’t understood from

  • 0

Hi i need to implement ActionBar in my application, but i haven’t understood from where to begin.

This example i wish to get
link

I have tested ShareLock and other stuff, but i couldn’t successfully to implement these examples, i need to get this result using Fragments and there should be 4 Tabs.

I have used android-support-v4.jar.

Here is my Fragment Utils that i use.

public class TabManager implements TabHost.OnTabChangeListener {
    private final FragmentActivity mActivity;
    private final TabHost mTabHost;
    private final int mContainerId;
    private final HashMap<String, TabInfo> mTabs = new HashMap<String, TabInfo>();
    TabInfo mLastTab;

    static final class TabInfo {
    private final String tag;
    private final Class<?> clss;
    private final Bundle args;
    private Fragment fragment;

    TabInfo(String _tag, Class<?> _class, Bundle _args) {
        tag = _tag;
        clss = _class;
        args = _args;
    }
}

static class DummyTabFactory implements TabHost.TabContentFactory {
    private final Context mContext;

    public DummyTabFactory(Context context) {
        mContext = context;
    }

    @Override
    public View createTabContent(String tag) {
        View v = new View(mContext);
        v.setMinimumWidth(0);
        v.setMinimumHeight(0);
        return v;
    }
}

public TabManager(FragmentActivity activity, TabHost tabHost, int containerId) {
    mActivity = activity;
    mTabHost = tabHost;
    mContainerId = containerId;
    mTabHost.setOnTabChangedListener(this);
}

public void addTab(TabHost.TabSpec tabSpec, Class<?> clss, Bundle args) {
    tabSpec.setContent(new DummyTabFactory(mActivity));
    String tag = tabSpec.getTag();

    TabInfo info = new TabInfo(tag, clss, args);

    // Check to see if we already have a fragment for this tab, probably
    // from a previously saved state.  If so, deactivate it, because our
    // initial state is that a tab isn't shown.
    info.fragment = mActivity.getSupportFragmentManager().findFragmentByTag(tag);
    if (info.fragment != null && !info.fragment.isDetached()) {
        FragmentTransaction ft = mActivity.getSupportFragmentManager().beginTransaction();
        ft.detach(info.fragment);
        ft.commit();
    }

    mTabs.put(tag, info);
    mTabHost.addTab(tabSpec);
}

@Override
public void onTabChanged(String tabId) {

    TabInfo newTab = mTabs.get(tabId);
    FragmentManager fragmentManager = mActivity.getSupportFragmentManager();
    if (mLastTab != newTab) {
        FragmentTransaction ft = fragmentManager.beginTransaction();
        if (mLastTab != null) {
            if (mLastTab.fragment != null) {
                ft.detach(mLastTab.fragment);
            }
        }
        fragmentManager.popBackStack(null, FragmentManager.POP_BACK_STACK_INCLUSIVE);
        if (newTab != null) {
            if (newTab.fragment == null) {
                newTab.fragment = Fragment.instantiate(mActivity,
                        newTab.clss.getName(), newTab.args);
                ft.add(mContainerId, newTab.fragment, newTab.tag);
            } else {
                ft.attach(newTab.fragment);
            }
        }
        mLastTab = newTab;
        ft.commit();
        mActivity.getSupportFragmentManager().executePendingTransactions();
    }
}

}

and some more….

public class FragmentsUtils {
private static String DIALOG_TAG = "dialog_tag";

/*public static MyAlertDialogFragment showDialog(FragmentManager fragmentManager, int id) {
    // DialogFragment.show() will take care of adding the fragment
    // in a transaction.  We also want to remove any currently showing
    // dialog, so make our own transaction and take care of that here.
    FragmentTransaction ft = fragmentManager.beginTransaction();
    Fragment prev = fragmentManager.findFragmentByTag(DIALOG_TAG);
    if (prev != null) {
        ft.remove(prev);
    }

    //      ft.addToBackStack(null);

    // Create and show the dialog.
    MyAlertDialogFragment newFragment = MyAlertDialogFragment.newInstance(id);
    newFragment.show(ft, DIALOG_TAG);
    return newFragment;
}*/

public static void swapFragments(FragmentManager fragmentManager, int containerViewId, Fragment newFragment, String fragmentTag) {

    if (fragmentManager == null)
        return;
    View newFragmentMainView = newFragment.getView();
    FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
    //      fragmentTransaction.replace(containerViewId, fragment);

    if (fragmentTag == null || fragmentTag.length() < 1)
        fragmentTransaction.add(containerViewId, newFragment);
    else
        fragmentTransaction.add(containerViewId, newFragment, fragmentTag);

    fragmentTransaction.addToBackStack(null);
    fragmentTransaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
    fragmentTransaction.commit();
}

public static void swapFragments(FragmentManager fragmentManager, int containerViewId, Fragment newFragment) {
    swapFragments(fragmentManager, containerViewId, newFragment, null);
}

}

Many thanks in advance…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T04:29:21+00:00Added an answer on June 17, 2026 at 4:29 am

    The ActionBar is only available from API 11 (3) on. If you attempt to run an application which is making use of the ActionBar on a device which is on API 10 (2.3.3 – 2.3.7) it will not be visible.

    If you need an ActionBar (essentially a robust offering to Tabs) in your application and plan to target API 10 or earlier devices, you can look the android-actionbar or ActionBarSherlock.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to implement simple file watcher utility. I have decided to implement this
Hi I need implement context help inside my .NET application. I have .chm file
I need to implement portable code, but I do not know how to deal
i need to implement a messaging scenario that consumes messages from throusands of destinations
I need to implement the search function on my custom map application like it
i have big decision tree with many Yes/No questions. i need implement some code
Yet another compatibility problem from me. BACKGROUND I have an application that works in
Need to implement Application Role Management feature.. Looked at AZMan , I guess it
I need implement something like this: {% include pay_forms/{{ pay_gw.name }}.html %} , where
I need to implement InApp Purchase in my monotouch app, but I cannot find

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.