Search in sources :

Example 31 with ActionBar

use of com.actionbarsherlock.app.ActionBar in project ActionBarSherlock by JakeWharton.

the class Issue882 method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.issue882);
    mPager = (ViewPager) findViewById(R.id.pager);
    mPager.setAdapter(new MyAdapter(getSupportFragmentManager()));
    mPager.setOnPageChangeListener(this);
    ActionBar ab = getSupportActionBar();
    ab.setNavigationMode(NAVIGATION_MODE_TABS);
    for (int i = 1; i <= COUNT; i++) {
        ab.addTab(ab.newTab().setText("Fragment " + i).setTabListener(this));
    }
}
Also used : ActionBar(com.actionbarsherlock.app.ActionBar)

Example 32 with ActionBar

use of com.actionbarsherlock.app.ActionBar in project ActionBarSherlock by JakeWharton.

the class MainActivity method showDropDownNav.

private void showDropDownNav() {
    ActionBar ab = getSupportActionBar();
    if (ab.getNavigationMode() != ActionBar.NAVIGATION_MODE_LIST) {
        ab.setDisplayShowTitleEnabled(false);
        ab.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
    }
}
Also used : ActionBar(com.actionbarsherlock.app.ActionBar)

Example 33 with ActionBar

use of com.actionbarsherlock.app.ActionBar in project ActionBarSherlock by JakeWharton.

the class MainActivity method onCreate.

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    final ActionBar ab = getSupportActionBar();
    // set defaults for logo & home up
    ab.setDisplayHomeAsUpEnabled(showHomeUp);
    ab.setDisplayUseLogoEnabled(useLogo);
    // set up tabs nav
    for (int i = 1; i < 4; i++) {
        ab.addTab(ab.newTab().setText("Tab " + i).setTabListener(this));
    }
    // set up list nav
    ab.setListNavigationCallbacks(ArrayAdapter.createFromResource(this, R.array.sections, R.layout.sherlock_spinner_dropdown_item), new OnNavigationListener() {

        public boolean onNavigationItemSelected(int itemPosition, long itemId) {
            // FIXME add proper implementation
            rotateLeftFrag();
            return false;
        }
    });
    // default to tab navigation
    showTabsNav();
    // create a couple of simple fragments as placeholders
    final int MARGIN = 16;
    leftFrag = new RoundedColourFragment(getResources().getColor(R.color.android_green), 1f, MARGIN, MARGIN / 2, MARGIN, MARGIN);
    rightFrag = new RoundedColourFragment(getResources().getColor(R.color.honeycombish_blue), 2f, MARGIN / 2, MARGIN, MARGIN, MARGIN);
    FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
    ft.add(R.id.root, leftFrag);
    ft.add(R.id.root, rightFrag);
    ft.commit();
}
Also used : OnNavigationListener(com.actionbarsherlock.app.ActionBar.OnNavigationListener) FragmentTransaction(android.support.v4.app.FragmentTransaction) ActionBar(com.actionbarsherlock.app.ActionBar)

Example 34 with ActionBar

use of com.actionbarsherlock.app.ActionBar in project SherlockNavigationDrawer by nicolasjafelle.

the class SherlockActionBarDrawerToggleCompat method setActionBarUpIndicator.

public static Object setActionBarUpIndicator(Object info, Activity activity, Drawable drawable, int contentDescRes) {
    if (info == null) {
        info = new SetIndicatorInfo(activity);
    }
    final SetIndicatorInfo sii = (SetIndicatorInfo) info;
    if (sii.setHomeAsUpIndicator != null) {
        try {
            final ActionBar actionBar = ((SherlockFragmentActivity) activity).getSupportActionBar();
            sii.setHomeAsUpIndicator.invoke(actionBar, drawable);
            sii.setHomeActionContentDescription.invoke(actionBar, contentDescRes);
        } catch (Exception e) {
            Log.w(TAG, "Couldn't set home-as-up indicator via JB-MR2 API", e);
        }
    } else if (sii.upIndicatorView != null) {
        sii.upIndicatorView.setImageDrawable(drawable);
    } else {
        Log.w(TAG, "Couldn't set home-as-up indicator");
    }
    return info;
}
Also used : SherlockFragmentActivity(com.actionbarsherlock.app.SherlockFragmentActivity) ActionBar(com.actionbarsherlock.app.ActionBar)

Aggregations

ActionBar (com.actionbarsherlock.app.ActionBar)34 Bundle (android.os.Bundle)5 TextView (android.widget.TextView)5 SherlockFragmentActivity (com.actionbarsherlock.app.SherlockFragmentActivity)3 Bitmap (android.graphics.Bitmap)2 GradientDrawable (android.graphics.drawable.GradientDrawable)2 FragmentTransaction (android.support.v4.app.FragmentTransaction)2 View (android.view.View)2 AdapterView (android.widget.AdapterView)2 Button (android.widget.Button)2 ImageView (android.widget.ImageView)2 LinearLayout (android.widget.LinearLayout)2 OnNavigationListener (com.actionbarsherlock.app.ActionBar.OnNavigationListener)2 FailReason (com.nostra13.universalimageloader.core.assist.FailReason)2 ImageLoadingListener (com.nostra13.universalimageloader.core.assist.ImageLoadingListener)2 Activity (org.holoeverywhere.app.Activity)2 DataSetObserver (android.database.DataSetObserver)1 Fragment (android.support.v4.app.Fragment)1 ViewPager (android.support.v4.view.ViewPager)1 LayoutInflater (android.view.LayoutInflater)1