Example usage for android.app Activity getActionBar

List of usage examples for android.app Activity getActionBar

Introduction

In this page you can find the example usage for android.app Activity getActionBar.

Prototype

@Nullable
public ActionBar getActionBar() 

Source Link

Document

Retrieve a reference to this activity's ActionBar.

Usage

From source file:com.android.talkback.tutorial.TutorialMainFragment.java

@Override
public void onResume() {
    super.onResume();
    Activity activity = getActivity();
    if (activity != null) {
        activity.getActionBar().setDisplayHomeAsUpEnabled(false);
        activity.getActionBar().setDisplayShowTitleEnabled(true);
        activity.getActionBar().setDisplayShowCustomEnabled(false);
    }//from   w  ww . ja  v a  2 s. co m
}

From source file:com.codebutler.farebot.ui.TabPagerAdapter.java

public TabPagerAdapter(Activity activity, ViewPager pager) {
    mActivity = activity;/*from   w  w  w . j  a  v  a2s  .co  m*/
    mActionBar = activity.getActionBar();
    mViewPager = pager;
    mViewPager.setAdapter(this);
    mViewPager.setOnPageChangeListener(this);
}

From source file:net.zhuoweizhang.scripteval.TabsAdapter.java

public TabsAdapter(Activity activity, ViewPager pager) {
    super(activity.getFragmentManager());
    mActivity = activity;//from w  w w.j  a v  a 2s  .  co m
    mActionBar = activity.getActionBar();
    mViewPager = pager;
    mViewPager.setAdapter(this);
    mViewPager.setOnPageChangeListener(this);
}

From source file:com.google.android.apps.mytracks.util.Api11Adapter.java

@Override
public void configureActionBarHomeAsUp(Activity activity) {
    activity.getActionBar().setDisplayHomeAsUpEnabled(true);
}

From source file:com.example.office.ui.mail.MailItemFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    mInflater = inflater;/*  ww w.j a  v  a  2  s  .c o m*/
    View rootView = inflater.inflate(getFragmentLayoutId(), container, false);
    setHasOptionsMenu(true);

    try {
        Activity activity = getActivity();
        activity.getActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);

        Intent intent = getActivity().getIntent();
        mail = (MailItem) intent.getExtras().get(getActivity().getString(R.string.intent_mail_key));
        displayMail(rootView);
        getActivity().setProgressBarIndeterminateVisibility(false);
    } catch (Exception e) {
        Logger.logApplicationException(e, getClass().getSimpleName() + ".onCreateView(): Error.");
    }

    return rootView;
}

From source file:Windows.UI.Xaml.Controls.CommandBar.java

public void show(android.app.Activity activity, android.view.Menu menu) {
    //if (!(activity instanceof ActionBarActivity)) {
    android.app.ActionBar mainActionBar = activity.getActionBar();
    if (mainActionBar != null) {
        mainActionBar.show();/*w ww . j  a va 2  s .c om*/
        if (_primaryCommands != null) {
            for (int i = 0; i < _primaryCommands.size(); i++) {
                menu.add(0, i, 0, ((AppBarButton) _primaryCommands.get(i)).label);
                menu.getItem(i).setShowAsAction(android.view.MenuItem.SHOW_AS_ACTION_ALWAYS);
            }
        }
        return;
    }
    throw new RuntimeException(
            "Cannot use TabBar on the main page in Android unless you set <preference name=\"ShowTitle\" value=\"true\"/> in config.xml.");
    //}
    //else {
    //    ActionBar actionBar = ((ActionBarActivity)activity).getSupportActionBar();
    //    if (actionBar != null) {
    //        actionBar.show();
    //        for (int i = 0; i < _primaryCommands.size(); i++) {
    //            menu.add(0, i, 0, ((AppBarButton)_primaryCommands.get(i)).label);
    //            menu.getItem(i).setShowAsAction(android.view.MenuItem.SHOW_AS_ACTION_ALWAYS);
    //        }
    //        return;
    //    }
    //    throw new RuntimeException(
    //        "Unable to get the action bar from the current activity.");
    //}
}

From source file:ca.mymenuapp.ui.widgets.SwipeableActionBarTabsAdapter.java

public SwipeableActionBarTabsAdapter(Activity activity, ViewPager pager,
        DelegateOnPageChangeListener delegate) {
    super(activity.getFragmentManager());
    context = activity;/*w w w .  ja v a 2  s.c o m*/
    actionBar = activity.getActionBar();
    viewPager = pager;
    viewPager.setAdapter(this);
    delegate.addOnPageChangeListener(this);
}

From source file:com.example.office.ui.calendar.EventFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    mInflater = inflater;/*  w  w  w  .  j  av  a 2s  .  c o  m*/
    View rootView = inflater.inflate(getFragmentLayoutId(), container, false);

    try {
        Activity activity = getActivity();
        activity.getActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);

        Intent intent = getActivity().getIntent();
        event = (Event) intent.getExtras().get(getActivity().getString(R.string.intent_event_key));
        displayEvent(rootView);
        getActivity().setProgressBarIndeterminateVisibility(false);

        // Code below will be invoked when we receive system intent holding the path to shared image and this image is transformed into bytes[].
        mImagePicker = new ImagePicker(getActivity(), getActivity().getString(R.string.intent_event_key)) {
            @Override
            public void processImage(final byte[] imageBytes, final String fileName, final Object intentArg) {
                try {
                    String itemId = "";
                    if (intentArg instanceof Event) {
                        itemId = ((Event) intentArg).getId();
                    }

                    if (!TextUtils.isEmpty(itemId)) {
                        // Getting event by id
                        Futures.addCallback(Me.getEvents().getAsync(itemId), new FutureCallback<IEvent>() {
                            @Override
                            public void onFailure(Throwable t) {
                                if (!onError(t)) {
                                    mImagePicker.showStatusToast(Status.UPLOAD_FAILED);
                                }
                            }

                            @Override
                            public void onSuccess(IEvent event) {
                                try {
                                    IFileAttachment attachment = event.getAttachments().newFileAttachment();
                                    attachment.setContentBytes(imageBytes).setName(fileName);
                                    // Propagating changes to server
                                    Me.flush();

                                    mImagePicker.showStatusToast(Status.UPLOAD_SUCCESS);
                                } catch (Exception e) {
                                    onFailure(e);
                                }
                            }
                        });
                    }
                } catch (Exception e) {
                    if (!onError(e)) {
                        mImagePicker.showStatusToast(Status.UPLOAD_FAILED);
                    }
                }
            }
        };
    } catch (Exception e) {
        Logger.logApplicationException(e, getClass().getSimpleName() + ".onCreateView(): Error.");
    }

    return rootView;
}

From source file:run.ace.TabBar.java

public void setTitle(String title, android.app.Activity activity) {
    //if (!(activity instanceof ActionBarActivity)) {
    android.app.ActionBar actionBar = activity.getActionBar();
    if (actionBar == null) {
        throw new RuntimeException(
                "Cannot set title on the main page in Android unless you set <preference name=\"ShowTitle\" value=\"true\"/> in config.xml.");
    }/* ww w  .j a va  2s .c om*/
    actionBar.setTitle(title);
    //}
    //else {
    //    ActionBar actionBar = ((ActionBarActivity)activity).getSupportActionBar();
    //    if (actionBar != null) {
    //        actionBar.setTitle(title);
    //    }
    //}
}

From source file:com.actionbarsherlock.sample.hcgallery.CameraFragment.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    // Add an up arrow to the "home" button, indicating that the button will go "up"
    // one activity in the app's Activity heirarchy.
    // Calls to getActionBar() aren't guaranteed to return the ActionBar when called
    // from within the Fragment's onCreate method, because the Window's decor hasn't been
    // initialized yet.  Either call for the ActionBar reference in Activity.onCreate()
    // (after the setContentView(...) call), or in the Fragment's onActivityCreated method.
    Activity activity = this.getActivity();
    ActionBar actionBar = activity.getActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);
}