List of usage examples for android.app ActionBar setHomeButtonEnabled
public void setHomeButtonEnabled(boolean enabled)
From source file:de.knufficast.ui.main.MainActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); queueFragment = new QueueFragment(); feedsFragment = new FeedsFragment(); setContentView(R.layout.activity_main); // Create the adapter that will return a fragment for each of the three primary sections // of the app. sectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager()); // Set up the action bar. final ActionBar actionBar = getActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); actionBar.setHomeButtonEnabled(false); // Set up the ViewPager with the sections adapter. viewPager = (ViewPager) findViewById(R.id.pager); viewPager.setAdapter(sectionsPagerAdapter); // 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./*w w w . j a v a 2 s . co m*/ viewPager.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 < sectionsPagerAdapter.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(sectionsPagerAdapter.getPageTitle(i)).setTabListener(this)); } }
From source file:info.ipeanut.googletrainingcoursedemos.effectivenavigation.MainActivity.java
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_effective); // 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 w w 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); // 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:com.numenta.taurus.instance.InstanceListActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); final SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); // Create content from resource setContentView(R.layout.activity_instance_list); // Get ListFragment _listFragment = (InstanceListFragment) getFragmentManager().findFragmentById(R.id.instance_list_fragment); // Add Filter menu ActionBar actionBar = getActionBar(); if (actionBar != null) { actionBar.setHomeButtonEnabled(false); actionBar.setDisplayShowCustomEnabled(true); actionBar.setCustomView(R.layout.actionbar_filter); _favorites = (RadioGroup) actionBar.getCustomView().findViewById(R.id.filter); if (_favorites != null) { _favorites.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { @Override/* www. j a v a2 s.co m*/ public void onCheckedChanged(RadioGroup group, int checkedId) { if (checkedId == R.id.filter_favorites) { clearNotifications(); _listFragment.filterFavorites(); } else { _listFragment.clearFilter(); } // Write the new viewState to the preferences pref.edit().putInt(TaurusPreferenceConstants.PREF_LAST_VIEW_STATE, checkedId).apply(); } }); int checkedId = R.id.filter_none; try { checkedId = pref.getInt(TaurusPreferenceConstants.PREF_LAST_VIEW_STATE, R.id.filter_none); } catch (ClassCastException e) { // Remove old preference value pref.edit().remove(TaurusPreferenceConstants.PREF_LAST_VIEW_STATE).apply(); } RadioButton button = (RadioButton) _favorites.findViewById(checkedId); if (button != null) { button.setChecked(true); } } } // Handle search queries if (getIntent() != null) { handleIntent(getIntent()); } // Check if we should show the tutorial page boolean skipTutorial = pref.getBoolean(PreferencesConstants.PREF_SKIP_TUTORIAL, false); if (!skipTutorial) { Intent myIntent = new Intent(this, TutorialActivity.class); startActivity(myIntent); overridePendingTransition(0, R.anim.fadeout_animation); } }
From source file:com.smbc2.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 www . java 2s .c om actionBar.setHomeButtonEnabled(false); // Specify that we will be displaying tabs in the action bar. actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); // 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:com.example.swipeuiforupclose.MainActivity.java
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.profile_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 w w w. ja va2 s.co m actionBar.setHomeButtonEnabled(false); actionBar.setBackgroundDrawable(new ColorDrawable(0xFF46304e)); actionBar.setStackedBackgroundDrawable(new ColorDrawable(0xFF573d5d)); actionBar.setTitle("My Profile"); // Specify that we will be displaying tabs in the action bar. //actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); // 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:net.callmeike.android.mojowire.ui.PodcastFragment.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 layout The DrawerLayout containing this fragment's UI. *///from ww w . ja v a2 s . c o m public void setUp(int fragmentId, DrawerLayout layout) { drawerLayout = layout; drawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START); fragmentContainerView = getActivity().findViewById(fragmentId); ActionBar actionBar = getActionBar(); actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setHomeButtonEnabled(true); // ActionBarDrawerToggle ties together the the proper interactions // between the navigation drawer and the action bar app icon. drawerToggle = new PodcastActionBarDrawerToggle(this, drawerLayout, R.drawable.ic_drawer, R.string.navigation_drawer_open, R.string.navigation_drawer_close); // If the user hasn't 'learned' about the drawer, open it to introduce them to the drawer, // per the navigation drawer design guidelines. if (!drawerHasBeenSeen && !fromSavedInstanceState) { this.drawerLayout.openDrawer(fragmentContainerView); } // Defer code dependent on restoration of previous instance state. this.drawerLayout.post(new Runnable() { @Override public void run() { drawerToggle.syncState(); } }); this.drawerLayout.setDrawerListener(drawerToggle); }
From source file:com.example.adbird.MenuTabActivity.java
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.tab_menu);//from ww w .j a v a 2 s .c o m mContext = this.getApplicationContext(); SharedPreferences prefs = getSharedPreferences("prefs", MODE_PRIVATE); String lang = prefs.getString("lang", null); Locale locale = new Locale(lang); Locale.setDefault(locale); Configuration config = new Configuration(); config.locale = locale; getBaseContext().getResources().updateConfiguration(config, getBaseContext().getResources().getDisplayMetrics()); SpannableString s = new SpannableString(mContext.getResources().getString(R.string.ads_title)); s.setSpan(new TypefaceSpan(this, "GothaProReg.otf"), 0, s.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); mAppSectionsPagerAdapter = new AppSectionsPagerAdapter(getSupportFragmentManager()); // Set up the action bar. final ActionBar actionBar = getActionBar(); actionBar.setTitle(s); actionBar.setHomeButtonEnabled(false); // Specify that we will be displaying tabs in the action bar. 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); SpannableString s = new SpannableString(mAppSectionsPagerAdapter.getPageTitle(position)); s.setSpan(new TypefaceSpan(getApplicationContext(), "GothaProReg.otf"), 0, s.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); actionBar.setTitle(s); } }); // For each of the sections in the app, add a tab to the action bar. for (int i = 0; i < mAppSectionsPagerAdapter.getCount(); i++) { actionBar.addTab( actionBar.newTab().setIcon(mAppSectionsPagerAdapter.getPageIcon(i)).setTabListener(this)); } }
From source file:com.agilemessage.ameffectivenavigation.MainActivity.java
@Override 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./*w ww .j av a 2 s . c o m*/ actionBar.setHomeButtonEnabled(true); // Specify that we will be displaying tabs in the action bar. actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); // 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); // Toast.makeText(getApplicationContext(), "onPageSelected, pos=" + position, // Toast.LENGTH_SHORT).show(); } }); // // 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)); // } actionBar.addTab(actionBar.newTab().setText("about").setTabListener(this)); actionBar.addTab(actionBar.newTab().setText("share").setTabListener(this)); actionBar.addTab(actionBar.newTab().setText("go").setTabListener(this)); }
From source file:com.tabs.viewpager.testt.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.// w w w . j a va2 s.co m actionBar.setHomeButtonEnabled(false); // Specify that we will be displaying tabs in the action bar. actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); // 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)); // } //adding tab 1 actionBar.addTab(actionBar.newTab().setText(R.string.title_orders).setTabListener(this)); //adding tab 2 actionBar.addTab(actionBar.newTab().setText(R.string.title_orders).setTabListener(this)); //adding tab 2 actionBar.addTab(actionBar.newTab().setText(R.string.title_my_profile).setTabListener(this)); }
From source file:org.yuzhiqiang.itsmine.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 ava 2s. c om public void setUp(int fragmentId, DrawerLayout 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.setDisplayHomeAsUpEnabled(true); actionBar.setHomeButtonEnabled(true); // ActionBarDrawerToggle ties together the the proper interactions // between the navigation drawer and the action bar app icon. mDrawerToggle = new ActionBarDrawerToggle(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; getActivity().invalidateOptionsMenu(); // calls onPrepareOptionsMenu() } @Override public void onDrawerOpened(View drawerView) { super.onDrawerOpened(drawerView); if (!isAdded()) return; if (!mUserLearnedDrawer) { // The user manually opened the drawer; store this flag to prevent auto-showing // the navigation drawer automatically in the future. mUserLearnedDrawer = true; SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(getActivity()); sp.edit().putBoolean(PREF_USER_LEARNED_DRAWER, true).apply(); } getActivity().invalidateOptionsMenu(); // calls onPrepareOptionsMenu() } }; // If the user hasn't 'learned' about the drawer, open it to introduce them to the drawer, // per the navigation drawer design guidelines. if (!mUserLearnedDrawer && !mFromSavedInstanceState) { mDrawerLayout.openDrawer(mFragmentContainerView); } // Defer code dependent on restoration of previous instance state. mDrawerLayout.post(new Runnable() { @Override public void run() { mDrawerToggle.syncState(); } }); mDrawerLayout.setDrawerListener(mDrawerToggle); }