List of usage examples for android.app ActionBar setHomeButtonEnabled
public void setHomeButtonEnabled(boolean enabled)
From source file:de.schramke.android.navdrawer.sample.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Log.addLogHandler(new DefaultAndroidLogHandler()); Log.setContext(this); setContentView(R.layout.activity_main); // enable ActionBar app icon to behave as action to toggle nav drawer final ActionBar actionBar = getActionBar(); if (actionBar != null) { actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setHomeButtonEnabled(true); }//from ww w .j a v a 2 s. co m }
From source file:com.trin.nilmobile.imageloader.ImagePagerActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.ac_image_pager); ActionBar actionBar = getActionBar(); actionBar.setHomeButtonEnabled(true); actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setTitle(""); Bundle bundle = getIntent().getExtras(); assert bundle != null; String[] imageUrls = bundle.getStringArray(Extra.IMAGES); int pagerPosition = bundle.getInt(Extra.IMAGE_POSITION, 0); if (savedInstanceState != null) { pagerPosition = savedInstanceState.getInt(STATE_POSITION); }/*from w ww . ja va2s . co m*/ options = new DisplayImageOptions.Builder().showImageForEmptyUri(R.drawable.ic_empty) .showImageOnFail(R.drawable.ic_error).resetViewBeforeLoading(true).cacheOnDisk(true) .imageScaleType(ImageScaleType.EXACTLY).bitmapConfig(Bitmap.Config.RGB_565).considerExifParams(true) .displayer(new FadeInBitmapDisplayer(300)).build(); pager = (ViewPager) findViewById(R.id.pager); pager.setAdapter(new ImagePagerAdapter(imageUrls)); pager.setCurrentItem(pagerPosition); }
From source file:com.bionx.res.about.InformationCenter.java
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.information_center); mAppSectionsPagerAdapter = new AppSectionsPagerAdapter(getSupportFragmentManager()); final ActionBar actionBar = getActionBar(); actionBar.setHomeButtonEnabled(true); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setAdapter(mAppSectionsPagerAdapter); mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override// w ww . j a v a 2s .c o m public void onPageSelected(int position) { actionBar.setSelectedNavigationItem(position); } }); for (int i = 0; i < mAppSectionsPagerAdapter.getCount(); i++) { actionBar.addTab( actionBar.newTab().setText(mAppSectionsPagerAdapter.getPageTitle(i)).setTabListener(this)); } }
From source file:com.example.android.tabbedroombookingtimetabledisplay.MainFragmentActivity.java
public void tabSettings(ActionBar actionBar) { try {/*from w w w .ja va2s .co m*/ actionBar.setHomeButtonEnabled(false); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); final Method setHasEmbeddedTabsMethod = actionBar.getClass().getDeclaredMethod("setHasEmbeddedTabs", boolean.class); setHasEmbeddedTabsMethod.setAccessible(true); setHasEmbeddedTabsMethod.invoke(actionBar, false); } catch (final Exception e) { // Handle issues as needed: log, warn user, fallback etc // This error is safe to ignore, standard tabs will appear. } }
From source file:com.matze5800.paupdater.MainActivity.java
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Set View// www .java2 s.co m setContentView(R.layout.activity_main); context = this; // Get SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); // ActionBar / PagerAdapter mAppSectionsPagerAdapter = new AppSectionsPagerAdapter(getFragmentManager()); final ActionBar actionBar = getActionBar(); actionBar.setHomeButtonEnabled(false); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setAdapter(mAppSectionsPagerAdapter); mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override public void onPageSelected(int position) { actionBar.setSelectedNavigationItem(position); } }); for (int i = 0; i < mAppSectionsPagerAdapter.getCount(); i++) { actionBar.addTab( actionBar.newTab().setText(mAppSectionsPagerAdapter.getPageTitle(i)).setTabListener(this)); } // Finishes Activity if device is not supported device = Functions.detectDevice(context); if (device.equals("unsupported")) { finish(); } }
From source file:edu.ufl.cise.android.MainActivity.java
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // Create the adapter that will return a fragment for each of the three primary sections // of the app. mAppSectionsPagerAdapter = new AppSectionsPagerAdapter(getSupportFragmentManager()); // Set up the action bar. final ActionBar actionBar = getActionBar(); // Specify that the Home/Up button should not be enabled, since there is no hierarchical // parent./*from ww w.ja va 2 s .c o m*/ actionBar.setHomeButtonEnabled(false); // Specify that we will be displaying tabs in the action bar. actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); actionBar.setDisplayShowHomeEnabled(false); actionBar.setDisplayShowTitleEnabled(false); actionBar.setDisplayUseLogoEnabled(false); // Set up the ViewPager, attaching the adapter and setting up a listener for when the // user swipes between sections. mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setAdapter(mAppSectionsPagerAdapter); mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override public void onPageSelected(int position) { // When swiping between different app sections, select the corresponding tab. // We can also use ActionBar.Tab#select() to do this if we have a reference to the // Tab. actionBar.setSelectedNavigationItem(position); } }); // For each of the sections in the app, add a tab to the action bar. for (int i = 0; i < mAppSectionsPagerAdapter.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 // listener for when this tab is selected. actionBar.addTab( actionBar.newTab().setText(mAppSectionsPagerAdapter.getPageTitle(i)).setTabListener(this)); } }
From source file:fm.krui.kruifm.StreamContainer.java
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.stream_container_layout); // Allow custom home button actions ActionBar actionBar = getActionBar(); actionBar.setHomeButtonEnabled(true); // Instantiate the Station Selection Fragment Fragment fragment = new StationSelectionFragment(); getSupportFragmentManager().beginTransaction() .replace(R.id.stream_fragment_container, fragment, Integer.toString(STATION_SELECT_TAB)).commit(); applyActionBarParameters(STATION_SELECT_TAB); currentFragment = (StationSelectionFragment) getSupportFragmentManager() .findFragmentById(STATION_SELECT_TAB); }
From source file:de.questmaster.fatremote.RemoteActivity.java
/** * Called when the activity is first created. * /* w w w. j ava 2 s .c o m*/ * @see android.app.Activity#onCreate(android.os.Bundle) */ @TargetApi(14) @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // setContentView(R.layout.remote_activity); // used in Honeycomb and up if (Build.VERSION.SDK_INT >= ANDROID_V11) { ActionBar ac = this.getActionBar(); if (ac != null) { ac.setDisplayHomeAsUpEnabled(true); if (Build.VERSION.SDK_INT >= ANDROID_V14) { ac.setHomeButtonEnabled(true); } } } if (savedInstanceState == null) { // During initial setup, plug in the details fragment. RemoteFragment details = new RemoteFragment(); details.setArguments(getIntent().getExtras()); getSupportFragmentManager().beginTransaction().add(android.R.id.content, details).commit(); } mSettings.readSettings(this); }
From source file:org.jorge.lolin1.ui.frags.NavigationDrawerFragment.java
/** * Users of this fragment must call this method to set up the navigation drawer interactions. * * @param fragmentId The android:id of this fragment in its activity's layout. * @param drawerLayout The DrawerLayout containing this fragment's UI. *///from w w w . j a v a 2 s . c o m public void setUp(int fragmentId, FixedDrawerLayout drawerLayout) { mFragmentContainerView = getActivity().findViewById(fragmentId); mDrawerLayout = drawerLayout; // set a custom shadow that overlays the main content when the drawer opens mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START); // set up the drawer's list view with items and click listener ActionBar actionBar = getActionBar(); actionBar.setHomeButtonEnabled(Boolean.TRUE); actionBar.setDisplayHomeAsUpEnabled(Boolean.TRUE); // ActionBarDrawerToggle ties together the the proper interactions // between the navigation drawer and the action bar app icon. mDrawerToggle = new FixedActionBarDrawerToggle(getActivity(), /* host Activity */ mDrawerLayout, /* DrawerLayout object */ R.drawable.ic_drawer, /* nav drawer image to replace 'Up' caret */ R.string.navigation_drawer_open, /* "open drawer" description for accessibility */ R.string.navigation_drawer_close /* "close drawer" description for accessibility */ ) { @Override public void onDrawerClosed(View drawerView) { super.onDrawerClosed(drawerView); if (!isAdded()) { return; } restoreActionBar(); getActivity().invalidateOptionsMenu(); } @Override public void onDrawerOpened(View drawerView) { super.onDrawerOpened(drawerView); showGlobalContextActionBar(); } }; // Defer code dependent on restoration of previous instance state. mDrawerLayout.post(new Runnable() { @Override public void run() { mDrawerToggle.syncState(); } }); mDrawerLayout.setDrawerListener(mDrawerToggle); }
From source file:org.iotivity.base.examples.DrawerFragment.java
public void setUp(int fragmentId, DrawerLayout drawerLayout) { mFragmentContainerView = getActivity().findViewById(fragmentId); mDrawerLayout = drawerLayout;// w ww . j av a2 s.c o m mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START); ActionBar actionBar = getActionBar(); actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setHomeButtonEnabled(true); mDrawerToggle = new ActionBarDrawerToggle(getActivity(), mDrawerLayout, R.drawable.ic_drawer, R.string.navigation_drawer_open, R.string.navigation_drawer_close) { @Override public void onDrawerClosed(View drawerView) { super.onDrawerClosed(drawerView); if (!isAdded()) { return; } getActivity().invalidateOptionsMenu(); } @Override public void onDrawerOpened(View drawerView) { super.onDrawerOpened(drawerView); if (!isAdded()) { return; } getActivity().invalidateOptionsMenu(); } }; mDrawerLayout.post(new Runnable() { @Override public void run() { mDrawerToggle.syncState(); } }); mDrawerLayout.setDrawerListener(mDrawerToggle); }