Search in sources :

Example 76 with ActionBar

use of android.app.ActionBar in project Android-Developers-Samples by johnjohndoe.

the class DoneBarActivity method onCreate.

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // BEGIN_INCLUDE (inflate_set_custom_view)
    // Inflate a "Done/Cancel" custom action bar view.
    final LayoutInflater inflater = (LayoutInflater) getActionBar().getThemedContext().getSystemService(LAYOUT_INFLATER_SERVICE);
    final View customActionBarView = inflater.inflate(R.layout.actionbar_custom_view_done_cancel, null);
    customActionBarView.findViewById(R.id.actionbar_done).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            // "Done"
            finish();
        }
    });
    customActionBarView.findViewById(R.id.actionbar_cancel).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            // "Cancel"
            finish();
        }
    });
    // Show the custom action bar view and hide the normal Home icon and title.
    final ActionBar actionBar = getActionBar();
    actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM, ActionBar.DISPLAY_SHOW_CUSTOM | ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_SHOW_TITLE);
    actionBar.setCustomView(customActionBarView, new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
    // END_INCLUDE (inflate_set_custom_view)
    setContentView(R.layout.activity_done_bar);
}
Also used : LayoutInflater(android.view.LayoutInflater) View(android.view.View) ActionBar(android.app.ActionBar)

Example 77 with ActionBar

use of android.app.ActionBar in project Android-Developers-Samples by johnjohndoe.

the class MainActivity method onCreate.

/**
     * Create the activity. Sets up an {@link android.app.ActionBar} with tabs, and then configures the
     * {@link ViewPager} contained inside R.layout.activity_main.
     *
     * <p>A {@link SectionsPagerAdapter} will be instantiated to hold the different pages of
     * fragments that are to be displayed. A
     * {@link android.support.v4.view.ViewPager.SimpleOnPageChangeListener} will also be configured
     * to receive callbacks when the user swipes between pages in the ViewPager.
     *
     * @param savedInstanceState
     */
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // Load the UI from res/layout/activity_main.xml
    setContentView(R.layout.sample_main);
    // Set up the action bar. The navigation mode is set to NAVIGATION_MODE_TABS, which will
    // cause the ActionBar to render a set of tabs. Note that these tabs are *not* rendered
    // by the ViewPager; additional logic is lower in this file to synchronize the ViewPager
    // state with the tab state. (See mViewPager.setOnPageChangeListener() and onTabSelected().)
    // BEGIN_INCLUDE (set_navigation_mode)
    final ActionBar actionBar = getActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    // END_INCLUDE (set_navigation_mode)
    // BEGIN_INCLUDE (setup_view_pager)
    // Create the adapter that will return a fragment for each of the three primary sections
    // of the app.
    mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
    // Set up the ViewPager with the sections adapter.
    mViewPager = (ViewPager) findViewById(R.id.pager);
    mViewPager.setAdapter(mSectionsPagerAdapter);
    // END_INCLUDE (setup_view_pager)
    // When swiping between different sections, select the corresponding tab. We can also use
    // ActionBar.Tab#select() to do this if we have a reference to the Tab.
    // BEGIN_INCLUDE (page_change_listener)
    mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {

        @Override
        public void onPageSelected(int position) {
            actionBar.setSelectedNavigationItem(position);
        }
    });
    // For each of the sections in the app, add a tab to the action bar.
    for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) {
        // Create a tab with text corresponding to the page title defined by the adapter. Also
        // specify this Activity object, which implements the TabListener interface, as the
        // callback (listener) for when this tab is selected.
        actionBar.addTab(actionBar.newTab().setText(mSectionsPagerAdapter.getPageTitle(i)).setTabListener(this));
    }
// END_INCLUDE (add_tabs)
}
Also used : ViewPager(android.support.v4.view.ViewPager) ActionBar(android.app.ActionBar)

Example 78 with ActionBar

use of android.app.ActionBar in project Talon-for-Twitter by klinker24.

the class TweetPager method setUpTheme.

public void setUpTheme() {
    Utils.setUpPopupTheme(context, settings);
    ActionBar actionBar = getActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);
    actionBar.setDisplayShowHomeEnabled(true);
    if (settings.addonTheme) {
        getWindow().getDecorView().setBackgroundColor(settings.backgroundColor);
    }
    Utils.setActionBar(context, !settings.advanceWindowed);
}
Also used : ActionBar(android.app.ActionBar)

Example 79 with ActionBar

use of android.app.ActionBar in project aFileChooser by iPaulPro.

the class FileChooserActivity method onCreateOptionsMenu.

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    if (HAS_ACTIONBAR) {
        boolean hasBackStack = mFragmentManager.getBackStackEntryCount() > 0;
        ActionBar actionBar = getActionBar();
        actionBar.setDisplayHomeAsUpEnabled(hasBackStack);
        actionBar.setHomeButtonEnabled(hasBackStack);
    }
    return true;
}
Also used : ActionBar(android.app.ActionBar)

Example 80 with ActionBar

use of android.app.ActionBar in project coursera-android by aporter.

the class DialtactsActivity method enterSearchUi.

/**
     * Hides every tab and shows search UI for phone lookup.
     */
private void enterSearchUi() {
    if (mSearchFragment == null) {
        // in this case.  Users can just hit it again and it will work this time.
        return;
    }
    if (mSearchView == null) {
        prepareSearchView();
    }
    final ActionBar actionBar = getActionBar();
    final Tab tab = actionBar.getSelectedTab();
    // User can search during the call, but we don't want to remember the status.
    if (tab != null && !DialpadFragment.phoneIsInUse()) {
        mLastManuallySelectedFragment = tab.getPosition();
    }
    mSearchView.setQuery(null, true);
    actionBar.setDisplayShowCustomEnabled(true);
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
    actionBar.setDisplayShowHomeEnabled(true);
    actionBar.setDisplayHomeAsUpEnabled(true);
    updateFakeMenuButtonsVisibility(false);
    for (int i = 0; i < TAB_INDEX_COUNT; i++) {
        sendFragmentVisibilityChange(i, false);
    }
    // Show the search fragment and hide everything else.
    mSearchFragment.setUserVisibleHint(true);
    final FragmentTransaction transaction = getFragmentManager().beginTransaction();
    transaction.show(mSearchFragment);
    transaction.commitAllowingStateLoss();
    mViewPager.setVisibility(View.GONE);
    // We need to call this and onActionViewCollapsed() manually, since we are using a custom
    // layout instead of asking the search menu item to take care of SearchView.
    mSearchView.onActionViewExpanded();
    mInSearchUi = true;
}
Also used : FragmentTransaction(android.app.FragmentTransaction) Tab(android.app.ActionBar.Tab) ActionBar(android.app.ActionBar)

Aggregations

ActionBar (android.app.ActionBar)158 View (android.view.View)37 Intent (android.content.Intent)19 AdapterView (android.widget.AdapterView)11 TextView (android.widget.TextView)11 ListView (android.widget.ListView)9 SharedPreferences (android.content.SharedPreferences)8 Uri (android.net.Uri)7 ArrayAdapter (android.widget.ArrayAdapter)7 FrameLayout (android.widget.FrameLayout)7 SpannableString (android.text.SpannableString)6 BitmapRegionTileSource (com.android.photos.BitmapRegionTileSource)6 GridLayoutManager (android.support.v7.widget.GridLayoutManager)5 RecyclerView (android.support.v7.widget.RecyclerView)5 CircularProgressButton (com.dd.CircularProgressButton)5 CircularProgressButton (com.marshalchen.common.uimodule.circularProgressButton.CircularProgressButton)5 SuppressLint (android.annotation.SuppressLint)4 Bundle (android.os.Bundle)4 ViewPager (android.support.v4.view.ViewPager)4 MenuInflater (android.view.MenuInflater)4