Example usage for android.app ActionBar setDisplayOptions

List of usage examples for android.app ActionBar setDisplayOptions

Introduction

In this page you can find the example usage for android.app ActionBar setDisplayOptions.

Prototype

public abstract void setDisplayOptions(@DisplayOptions int options);

Source Link

Document

Set display options.

Usage

From source file:com.eftimoff.viewpagertransformers.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    int selectedPage = 0;
    if (savedInstanceState != null) {
        mSelectedItem = savedInstanceState.getInt(KEY_SELECTED_CLASS);
        selectedPage = savedInstanceState.getInt(KEY_SELECTED_PAGE);
    }/*from  w  ww .j a v  a  2  s.  c o m*/

    final ArrayAdapter<TransformerItem> actionBarAdapter = new ArrayAdapter<TransformerItem>(
            getApplicationContext(), android.R.layout.simple_list_item_1, android.R.id.text1,
            TRANSFORM_CLASSES);

    final ActionBar actionBar = getActionBar();
    actionBar.setListNavigationCallbacks(actionBarAdapter, this);
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
    actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_TITLE);

    setContentView(R.layout.activity_main);

    mAdapter = new PageAdapter(getSupportFragmentManager());

    mPager = (ViewPager) findViewById(R.id.container);
    mPager.setAdapter(mAdapter);
    mPager.setCurrentItem(selectedPage);

    actionBar.setSelectedNavigationItem(mSelectedItem);
}

From source file:org.floens.chan.ui.activity.ImageViewActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
    ActionBar actionBar = getActionBar();
    actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_TITLE | ActionBar.DISPLAY_HOME_AS_UP);

    super.onCreate(savedInstanceState);

    if (postAdapterStatic == null || threadManagerStatic == null) {
        Logger.e(TAG, "postadapter or threadmanager null");
        finish();// w w  w.  ja  v  a  2 s  . c  o  m
        return;
    }

    threadManager = threadManagerStatic;
    threadManagerStatic = null;
    postAdapter = postAdapterStatic;
    postAdapterStatic = null;
    int selectedId = selectedIdStatic;
    selectedIdStatic = -1;

    ThemeHelper.setTheme(this);

    progressBar = new ProgressBar(this, null, android.R.attr.progressBarStyleHorizontal);
    progressBar.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT,
            FrameLayout.LayoutParams.WRAP_CONTENT));
    progressBar.setProgressDrawable(getResources().getDrawable(R.drawable.progressbar_no_bg));
    progressBar.setIndeterminate(false);
    progressBar.setMax(1000000);

    final FrameLayout decorView = (FrameLayout) getWindow().getDecorView();
    decorView.addView(progressBar);

    progressBar.post(new Runnable() {
        @Override
        public void run() {
            View contentView = decorView.findViewById(android.R.id.content);
            progressBar.setY(contentView.getY() - progressBar.getHeight() / 2);
        }
    });

    // Get the posts with images
    ArrayList<Post> imagePosts = new ArrayList<>();
    for (Post post : postAdapter.getList()) {
        if (post.hasImage) {
            imagePosts.add(post);
        }
    }

    // Setup our pages and adapter
    setContentView(R.layout.image_pager);
    viewPager = (ViewPager) findViewById(R.id.image_pager);
    adapter = new ImageViewAdapter(getFragmentManager(), this);
    adapter.setList(imagePosts);
    viewPager.setAdapter(adapter);
    viewPager.setOnPageChangeListener(this);

    // Select the right image
    for (int i = 0; i < imagePosts.size(); i++) {
        if (imagePosts.get(i).no == selectedId) {
            viewPager.setCurrentItem(i);
            onPageSelected(i);
            break;
        }
    }
}

From source file:com.aboveware.actionbar.honeycomb.ActionBarHelperHoneycomb.java

@Override
public void setDisplayOptions(int options) {
    ActionBar bar = mActivity.getActionBar();
    bar.setDisplayOptions(options);
}

From source file:org.bohrmeista.chan.ui.activity.ImageViewActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
    ActionBar actionBar = getActionBar();
    actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_TITLE | ActionBar.DISPLAY_HOME_AS_UP);

    super.onCreate(savedInstanceState);

    if (postAdapter == null) {
        Logger.e(TAG, "Posts in ImageViewActivity was null");
        finish();/* w w w.j  ava 2s.  c o m*/
        return;
    }

    threadManager = threadManagerStatic;

    ThemeHelper.setTheme(this);

    progressBar = new ProgressBar(this, null, android.R.attr.progressBarStyleHorizontal);
    progressBar.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT,
            FrameLayout.LayoutParams.WRAP_CONTENT));
    progressBar.setProgressDrawable(getResources().getDrawable(R.drawable.progressbar_no_bg));
    progressBar.setIndeterminate(false);
    progressBar.setMax(1000000);

    final FrameLayout decorView = (FrameLayout) getWindow().getDecorView();
    decorView.addView(progressBar);

    progressBar.post(new Runnable() {
        @Override
        public void run() {
            View contentView = decorView.findViewById(android.R.id.content);
            progressBar.setY(contentView.getY() - progressBar.getHeight() / 2);
        }
    });

    // Get the posts with images
    ArrayList<Post> imagePosts = new ArrayList<>();
    for (Post post : postAdapter.getList()) {
        if (post.images.size() > 0) {
            imagePosts.add(post);
        }
    }

    // Setup our pages and adapter
    setContentView(R.layout.image_pager);
    viewPager = (ViewPager) findViewById(R.id.image_pager);
    imageAdapter = new ImageViewAdapter(getFragmentManager(), this);
    imageAdapter.setList(imagePosts);
    viewPager.setAdapter(imageAdapter);
    viewPager.setOnPageChangeListener(this);

    // Select the right image
    int imageIndex = 0;
    for (Post post : imagePosts) {
        if (post.no == selectedId) {
            viewPager.setCurrentItem(imageIndex);
            onPageSelected(imageIndex);

            thumbList = (TwoWayView) findViewById(R.id.thumbList);
            thumbListAdapter = new ThumbListAdapter(this, post.images, imageIndex);
            thumbList.setAdapter(thumbListAdapter);
            thumbList.setVisibility(post.images.size() <= 1 ? View.GONE : View.VISIBLE);
            return;
        }
        imageIndex += post.images.size();
    }
}

From source file:com.stockbrowser.ComboViewActivity.java

@TargetApi(14)
@Override/* w  ww  . j  a  va 2 s.  co  m*/
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setResult(RESULT_CANCELED);
    Bundle extras = getIntent().getExtras();
    Bundle args = extras.getBundle(EXTRA_COMBO_ARGS);
    // 
    //        String svStr = extras.getString(EXTRA_INITIAL_VIEW, null);
    String svStr = extras.getString(EXTRA_INITIAL_VIEW);
    UI.ComboViews startingView = svStr != null ? UI.ComboViews.valueOf(svStr) : UI.ComboViews.Bookmarks;
    mViewPager = new ViewPager(this);
    mViewPager.setId(R.id.tab_view);
    setContentView(mViewPager);

    final ActionBar bar = getActionBar();
    bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    if (BrowserActivity.isTablet(this)) {
        bar.setDisplayOptions(ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_USE_LOGO);
        bar.setHomeButtonEnabled(true);
    } else {
        bar.setDisplayOptions(0);
    }

    mTabsAdapter = new TabsAdapter(this, mViewPager);
    mTabsAdapter.addTab(bar.newTab().setText(R.string.tab_bookmarks), BrowserBookmarksPage.class, args);

    if (savedInstanceState != null) {
        bar.setSelectedNavigationItem(savedInstanceState.getInt(STATE_SELECTED_TAB, 0));
    } else {
        switch (startingView) {
        case Bookmarks:
            mViewPager.setCurrentItem(0);
            break;
        case History:
            mViewPager.setCurrentItem(1);
            break;
        case Snapshots:
            mViewPager.setCurrentItem(2);
            break;
        }
    }
}

From source file:com.android.browser.ComboViewActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setResult(RESULT_CANCELED);//from  w  w w. j  av  a2 s.c  o  m
    Bundle extras = getIntent().getExtras();
    Bundle args = extras.getBundle(EXTRA_COMBO_ARGS);
    String svStr = extras.getString(EXTRA_INITIAL_VIEW, null);
    ComboViews startingView = svStr != null ? ComboViews.valueOf(svStr) : ComboViews.Bookmarks;
    mViewPager = new ViewPager(this);
    mViewPager.setId(R.id.tab_view);
    setContentView(mViewPager);

    final ActionBar bar = getActionBar();
    bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    if (BrowserActivity.isTablet(this)) {
        bar.setDisplayOptions(ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_USE_LOGO);
        bar.setHomeButtonEnabled(true);
    } else {
        bar.setDisplayOptions(0);
    }

    mTabsAdapter = new TabsAdapter(this, mViewPager);
    mTabsAdapter.addTab(bar.newTab().setText(R.string.tab_bookmarks), BrowserBookmarksPage.class, args);
    mTabsAdapter.addTab(bar.newTab().setText(R.string.tab_history), BrowserHistoryPage.class, args);

    if (savedInstanceState != null) {
        bar.setSelectedNavigationItem(savedInstanceState.getInt(STATE_SELECTED_TAB, 0));
    } else {
        switch (startingView) {
        case Bookmarks:
            mViewPager.setCurrentItem(0);
            break;
        case History:
            mViewPager.setCurrentItem(1);
            break;
        case Snapshots:
            mViewPager.setCurrentItem(2);
            break;
        }
    }
}

From source file:com.android.xbrowser.ComboViewActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setResult(RESULT_CANCELED);/*  w  ww  .ja v a  2  s  .co  m*/
    Bundle extras = getIntent().getExtras();
    Bundle args = extras.getBundle(EXTRA_COMBO_ARGS);
    String svStr = extras.getString(EXTRA_INITIAL_VIEW, null);
    ComboViews startingView = svStr != null ? ComboViews.valueOf(svStr) : ComboViews.Bookmarks;
    mViewPager = new ViewPager(this);
    mViewPager.setId(R.id.tab_view);
    setContentView(mViewPager);

    final ActionBar bar = getActionBar();
    bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    if (BrowserActivity.isTablet(this)) {
        bar.setDisplayOptions(ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_USE_LOGO);
    } else {
        bar.setDisplayOptions(0);
    }

    mTabsAdapter = new TabsAdapter(this, mViewPager);
    mTabsAdapter.addTab(bar.newTab().setText(R.string.tab_bookmarks), BrowserBookmarksPage.class, args);
    mTabsAdapter.addTab(bar.newTab().setText(R.string.tab_history), BrowserHistoryPage.class, args);
    mTabsAdapter.addTab(bar.newTab().setText(R.string.tab_snapshots), BrowserSnapshotPage.class, args);

    if (savedInstanceState != null) {
        bar.setSelectedNavigationItem(savedInstanceState.getInt(STATE_SELECTED_TAB, 0));
    } else {
        switch (startingView) {
        case Bookmarks:
            mViewPager.setCurrentItem(0);
            break;
        case History:
            mViewPager.setCurrentItem(1);
            break;
        case Snapshots:
            mViewPager.setCurrentItem(2);
            break;
        }
    }
}

From source file:com.baohume.browser.ComboViewActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setResult(RESULT_CANCELED);// ww  w  .  j a v a  2s. co  m
    Bundle extras = getIntent().getExtras();
    Bundle args = extras.getBundle(EXTRA_COMBO_ARGS);
    String svStr = extras.getString(EXTRA_INITIAL_VIEW, null);
    UI.ComboViews startingView = svStr != null ? UI.ComboViews.valueOf(svStr) : UI.ComboViews.Bookmarks;
    mViewPager = new ViewPager(this);
    mViewPager.setId(R.id.tab_view);
    setContentView(mViewPager);

    final ActionBar bar = getActionBar();
    bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    if (BrowserActivity.isTablet(this)) {
        bar.setDisplayOptions(ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_USE_LOGO);
        bar.setHomeButtonEnabled(true);
    } else {
        bar.setDisplayOptions(0);
    }

    mTabsAdapter = new TabsAdapter(this, mViewPager);
    mTabsAdapter.addTab(bar.newTab().setText(R.string.tab_bookmarks), BrowserBookmarksPage.class, args);
    mTabsAdapter.addTab(bar.newTab().setText(R.string.tab_history), BrowserHistoryPage.class, args);
    mTabsAdapter.addTab(bar.newTab().setText(R.string.tab_snapshots), BrowserSnapshotPage.class, args);

    if (savedInstanceState != null) {
        bar.setSelectedNavigationItem(savedInstanceState.getInt(STATE_SELECTED_TAB, 0));
    } else {
        switch (startingView) {
        case Bookmarks:
            mViewPager.setCurrentItem(0);
            break;
        case History:
            mViewPager.setCurrentItem(1);
            break;
        case Snapshots:
            mViewPager.setCurrentItem(2);
            break;
        }
    }
}

From source file:com.amen.browser.ComboViewActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setResult(RESULT_CANCELED);//from w w w  .  j a  v a  2s . co  m
    Bundle extras = getIntent().getExtras();
    Bundle args = extras.getBundle(EXTRA_COMBO_ARGS);
    String svStr = extras.getString(EXTRA_INITIAL_VIEW, null);
    ComboViews startingView = svStr != null ? ComboViews.valueOf(svStr) : ComboViews.Bookmarks;
    mViewPager = new ViewPager(this);
    mViewPager.setId(R.id.tab_view);
    setContentView(mViewPager);

    final ActionBar bar = getActionBar();
    bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    if (BrowserActivity.isTablet(this)) {
        bar.setDisplayOptions(ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_USE_LOGO);
        bar.setHomeButtonEnabled(true);
    } else {
        bar.setDisplayOptions(0);
    }

    mTabsAdapter = new TabsAdapter(this, mViewPager);
    /* mTabsAdapter.addTab(bar.newTab().setText(R.string.tab_bookmarks),
        BrowserBookmarksPage.class, args);*/
    mTabsAdapter.addTab(bar.newTab().setText(R.string.tab_history), BrowserHistoryPage.class, args);

    if (savedInstanceState != null) {
        bar.setSelectedNavigationItem(savedInstanceState.getInt(STATE_SELECTED_TAB, 0));
    } else {
        switch (startingView) {
        case Bookmarks:
            mViewPager.setCurrentItem(0);
            break;
        case History:
            mViewPager.setCurrentItem(1);
            break;
        case Snapshots:
            mViewPager.setCurrentItem(2);
            break;
        }
    }
}

From source file:com.android.stockbrowser.ComboViewActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setResult(RESULT_CANCELED);//from  w  w  w . ja  v a2 s  .  co  m
    Bundle extras = getIntent().getExtras();
    Bundle args = extras.getBundle(EXTRA_COMBO_ARGS);
    String svStr = extras.getString(EXTRA_INITIAL_VIEW, null);
    ComboViews startingView = svStr != null ? ComboViews.valueOf(svStr) : ComboViews.Bookmarks;
    mViewPager = new ViewPager(this);
    mViewPager.setId(R.id.tab_view);
    setContentView(mViewPager);

    final ActionBar bar = getActionBar();
    bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    if (BrowserActivity.isTablet(this)) {
        bar.setDisplayOptions(ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_USE_LOGO);
        bar.setHomeButtonEnabled(true);
    } else {
        bar.setDisplayOptions(0);
    }

    mTabsAdapter = new TabsAdapter(this, mViewPager);
    mTabsAdapter.addTab(bar.newTab().setText(R.string.tab_bookmarks), BrowserBookmarksPage.class, args);
    mTabsAdapter.addTab(bar.newTab().setText(R.string.tab_history), BrowserHistoryPage.class, args);
    mTabsAdapter.addTab(bar.newTab().setText(R.string.tab_snapshots), BrowserSnapshotPage.class, args);

    if (savedInstanceState != null) {
        bar.setSelectedNavigationItem(savedInstanceState.getInt(STATE_SELECTED_TAB, 0));
    } else {
        switch (startingView) {
        case Bookmarks:
            mViewPager.setCurrentItem(0);
            break;
        case History:
            mViewPager.setCurrentItem(1);
            break;
        case Snapshots:
            mViewPager.setCurrentItem(2);
            break;
        }
    }
}