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);
}
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)
}
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);
}
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;
}
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;
}
Aggregations