List of usage examples for android.app ActionBar setHomeButtonEnabled
public void setHomeButtonEnabled(boolean enabled)
From source file:com.witmob.nocollapsetabs.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(); actionBar.setDisplayShowHomeEnabled(false); actionBar.setDisplayShowTitleEnabled(false); // Specify that the Home/Up button should not be enabled, since there is no hierarchical // parent.//from w w w . j a va 2s. c o m actionBar.setHomeButtonEnabled(false); // Specify that we will be displaying tabs in the action bar. // 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)); } actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); }
From source file:com.dooweb.flip.TestProfile.java
public void onCreate(Bundle savedInstanceState) { Log.v("profile", "create"); super.onCreate(savedInstanceState); Log.v("profile", "super"); setContentView(R.layout.test_profile); // Create the adapter that will return a fragment for each of the three primary sections // of the app. Log.v("profile", "new adapter"); mAppSectionsPagerAdapter = new AppSectionsPagerAdapter(getSupportFragmentManager()); // Set up the action bar. Log.v("profile", "actionbar"); final ActionBar actionBar = getActionBar(); // Specify that the Home/Up button should not be enabled, since there is no hierarchical // parent.//from ww w . ja v a 2 s .c o m Log.v("profile", "homebutton"); actionBar.setHomeButtonEnabled(false); // Specify that we will be displaying tabs in the action bar. Log.v("profile", "setnav"); 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. Log.v("profile", "viewpager"); 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.jenil.parsedemo.GameShowActivity.java
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getWindow().requestFeature(Window.FEATURE_ACTION_BAR); setContentView(R.layout.activity_game_show_adapter); // 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./* ww w . j a va2 s .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.pagerShow); 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:ca.psiphon.ploggy.ActivityMain.java
@Override protected 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. mAppTabsPagerAdapter = new AppTabsPagerAdapter(getSupportFragmentManager()); final ActionBar actionBar = getActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); // Specify that the Home/Up button should not be enabled, since there is // no hierarchical parent. actionBar.setHomeButtonEnabled(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(mAppTabsPagerAdapter); mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override//w w w . j a va 2s . c o m 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); } }); actionBar.addTab(actionBar.newTab().setText(R.string.title_self_status_fragment).setTabListener(this)); actionBar.addTab(actionBar.newTab().setText(R.string.title_friend_list_fragment).setTabListener(this)); actionBar.addTab(actionBar.newTab().setText(R.string.title_message_list_fragment).setTabListener(this)); mMessageListTabIndex = 2; if (savedInstanceState != null) { actionBar.setSelectedNavigationItem(savedInstanceState.getInt("currentTab", 0)); } }
From source file:com.mac.SafeWalk.WelcomeActivity.java
/** * Called when the activity is first created. *///from w w w. jav a2s . c o m @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH) @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.welcome_screen); // Create adapter collectionPagerAdapter = new CollectionPagerAdapter(getSupportFragmentManager()); // Set up action bar. final ActionBar actionBar = getActionBar(); actionBar.hide(); // Specify that the Home/Up button should not be enabled, since there is no hierarchical parent. actionBar.setHomeButtonEnabled(false); // Specify that we will be displaying tabs in the action bar. actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); // Set up the ViewPager // Attache the adapter and implement listener in order to respond when user swipes between sections. viewPager = (ViewPager) findViewById(R.id.pager); viewPager.setAdapter(collectionPagerAdapter); viewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override public void onPageSelected(int position) { // Select the corresponding tab when user swipes actionBar.setSelectedNavigationItem(position); ImageView dot1 = (ImageView) findViewById(R.id.sliding_dot1); ImageView dot2 = (ImageView) findViewById(R.id.sliding_dot2); switch (position) { case 0: animate(dot1); break; case 1: animate(dot2); break; case 2: break; } } }); // For each of the sections, add tab to the action bar. for (int i = 0; i < collectionPagerAdapter.getCount(); i++) { // Create tabs actionBar.addTab(actionBar.newTab().setTabListener(this)); } Settings.getSettings().setContext(this); }
From source file:de.d120.ophasekistenstapeln.NavigationDrawerFragment.java
/** * Users of this fragment must call this method to set up the navigation * drawer interactions./* www .ja v a 2s.com*/ * * @param fragmentId The android:id of this fragment in its activity's layout. * @param drawerLayout The DrawerLayout containing this fragment's UI. */ 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); }
From source file:com.example.android.navigationdrawerexample.activities.MainActivity.java
private void setUpDrawerButton(ActionBar actionBar) { // ????NavigationDrawer????? actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setHomeButtonEnabled(true); }
From source file:com.dvdprime.mobile.android.ui.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. 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// w ww . java 2s .c o m 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); EasyTracker.getTracker().sendView(AppSectionsPagerAdapter.tabEngTitles[position]); LOGD("Tracker", AppSectionsPagerAdapter.tabEngTitles[position]); // Save position value in preference PrefUtil.getInstance().setInt(PrefKeys.LAST_TAB_POSITION, 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)); } // Google Analytics EasyTracker.getInstance().setContext(this); EasyTracker.getTracker().sendView("Main"); LOGD("Tracker", "Main"); // Set Last Tab lastPosition = PrefUtil.getInstance().getInt(PrefKeys.LAST_TAB_POSITION, 0); actionBar.setSelectedNavigationItem(lastPosition); // . if (PrefUtil.getInstance().getString(PrefKeys.ACCOUNT_ID, null) != null) { JsonObjectRequest filterReq = new JsonObjectRequest( StringUtil.format(Config.MOBILE_DP_COUNT, PrefUtil.getInstance().getString(PrefKeys.ACCOUNT_ID, null)), null, createJsonReqSuccessListener(), createJsonReqErrorListener()); filterReq.setTag(TAG); DpApp.getRequestQueue().add(filterReq); } // ? if (SystemUtil.getVersionName(this).equals("1.0") && PrefUtil.getInstance().getBoolean(PrefKeys.VERSION_1_0, true)) { String msg = new StringBuffer().append("[1.0 ]\n\n").append( "-? \n ? ?? ? ? ?? /?.\n\n") .append("- \n ? ? ?. ? ? ?.") .toString(); new AlertDialog.Builder(this).setTitle(getString(R.string.alert_dialog_version)).setMessage(msg) .setCancelable(false) .setPositiveButton(getString(R.string.alert_dialog_ok), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { PrefUtil.getInstance().setBoolean(PrefKeys.VERSION_1_0, false); dialog.dismiss(); } }).create().show(); } }
From source file:edu.tcfsh.arrivinglaterecordapp.MainActivity.java
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main_activity); getBundle();//from w ww .j a v a 2 s. c o m arrivingLateRecordFragment = new ArrivingLateRecordFragment(dayOfMonth, month, year); // Create the adapter that will return a fragment for each of the three // primary sections // of the app. mAppSectionsPagerAdapter = new AppSectionsPagerAdapter(getSupportFragmentManager()); leavingActivityDialog = new AlertDialog.Builder(this, AlertDialog.THEME_HOLO_LIGHT); leavingActivityDialog.setTitle("??"); leavingActivityDialog.setMessage("?"); leavingActivityDialog.setPositiveButton("", new DialogInterface.OnClickListener() { public void onClick(DialogInterface arg0, int arg1) { savingFileAlertDialog.show(); } }); leavingActivityDialog.setNegativeButton("?", new DialogInterface.OnClickListener() { public void onClick(DialogInterface arg0, int arg1) { } }); savingFileAlertDialog = new AlertDialog.Builder(this, AlertDialog.THEME_HOLO_LIGHT); savingFileAlertDialog.setTitle("??"); savingFileAlertDialog.setMessage("?????"); savingFileAlertDialog.setPositiveButton("", new DialogInterface.OnClickListener() { public void onClick(DialogInterface arg0, int arg1) { arrivingLateRecordFragment.saveArrivingLateRecordFile(); finish(); } }); savingFileAlertDialog.setNegativeButton("?", new DialogInterface.OnClickListener() { public void onClick(DialogInterface arg0, int arg1) { finish(); } }); // 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. 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:fr.cph.chicago.fragment.drawer.NavigationDrawerFragment.java
/** * Users of this fragment must call this method to set up the navigation drawer interactions. * /* w ww.ja va 2s.c o m*/ * @param fragmentId * The android:id of this fragment in its activity's layout. * @param drawerLayout * The DrawerLayout containing this fragment's UI. */ public final void setUp(final int fragmentId, final 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; } if (mPendingRunnable != null) { Handler mHandler = new Handler(); mHandler.post(mPendingRunnable); mPendingRunnable = null; } 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); }