List of usage examples for android.app ActionBar setHomeButtonEnabled
public void setHomeButtonEnabled(boolean enabled)
From source file:org.digitalcampus.oppia.activity.DownloadActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_download); ActionBar actionBar = getActionBar(); if (actionBar != null) { actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setHomeButtonEnabled(true); }/*from ww w. j ava2 s . c o m*/ prefs = PreferenceManager.getDefaultSharedPreferences(this); Bundle bundle = this.getIntent().getExtras(); if (bundle != null) { Tag t = (Tag) bundle.getSerializable(Tag.TAG); this.url = MobileLearning.SERVER_TAG_PATH + String.valueOf(t.getId()) + File.separator; } else { this.url = MobileLearning.SERVER_COURSES_PATH; this.showUpdatesOnly = true; } courses = new ArrayList<CourseIntallViewAdapter>(); dla = new DownloadCourseListAdapter(this, courses); dla.setOnClickListener(new CourseListListener()); ListView listView = (ListView) findViewById(R.id.tag_list); listView.setAdapter(dla); }
From source file:no.invisibleink.app.MainActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); /* -------------------------------- Init ---------------- */ serverManager = new ServerManager(); locationManager = new LocationManager(this); locationManager.onCreate();//from ww w . j a va2s. c o m /* -------------------------------- Swipe view with taps ---------------- */ fragmentManager = getSupportFragmentManager(); listSectionFragment = new ListViewFragment(); mapSectionFragment = new MapViewFragment(); postSectionFragment = new PostViewFragment(); // Create the adapter that will return a fragment for each of the three primary sections // of the app. mAppSectionsPagerAdapter = new AppSectionsPagerAdapter(fragmentManager); // 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); } }); /* * Set the number of pages that should be retained to either side of the * current page in the view hierarchy in an idle state. Pages beyond * this limit will be recreated from the adapter when needed. */ mViewPager.setOffscreenPageLimit(3); // 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)); } try { MapsInitializer.initialize(getApplicationContext()); } catch (GooglePlayServicesNotAvailableException e) { Log.e(TAG, "Google play services is not available."); } }
From source file:edu.rutgers.winlab.crowdpp.ui.MainActivity.java
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main_activity_layout); // 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//from ww w . j a va 2 s. c om 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)); } SharedPreferences settings = this.getSharedPreferences("config", Context.MODE_PRIVATE); ; SharedPreferences.Editor editor = settings.edit(); // load the default parameters into SharedPreferences for the first time launch int ct = settings.getInt("count", 0); if (ct == 0) { editor.putString("start", "9"); editor.putString("end", "21"); editor.putString("interval", "15"); editor.putString("duration", "5"); editor.putString("location", "On"); editor.putString("upload", "On"); TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE); editor.putString("IMEI", tm.getDeviceId()); editor.putString("brand", Build.BRAND); editor.putString("model", Build.MODEL); String phone_type = Build.BRAND + "_" + Build.MODEL; // motoX if (phone_type.equals("motorola_XT1058")) { editor.putString("mfcc_dist_same_semi", "13"); editor.putString("mfcc_dist_diff_semi", "18"); editor.putString("mfcc_dist_same_un", "13"); editor.putString("mfcc_dist_diff_un", "18"); } // nexus 4 else if (phone_type.equals("google_Nexus 4")) { editor.putString("mfcc_dist_same_semi", "17"); editor.putString("mfcc_dist_diff_semi", "22"); editor.putString("mfcc_dist_same_un", "17"); editor.putString("mfcc_dist_diff_un", "22"); } // s2 else if (phone_type.equals("samsung_SAMSUNG-SGH-I727")) { editor.putString("mfcc_dist_same_semi", "18"); editor.putString("mfcc_dist_diff_semi", "25"); editor.putString("mfcc_dist_same_un", "18"); editor.putString("mfcc_dist_diff_un", "25"); } // s3 else if (phone_type.equals("samsung_SAMSUNG-SGH-I747")) { editor.putString("mfcc_dist_same_semi", "16"); editor.putString("mfcc_dist_diff_semi", "21"); editor.putString("mfcc_dist_same_un", "16"); editor.putString("mfcc_dist_diff_un", "21"); } // s4 else if (phone_type.equals("samsung_SAMSUNG-SGH-I337")) { editor.putString("mfcc_dist_same_semi", "14"); editor.putString("mfcc_dist_diff_semi", "24"); editor.putString("mfcc_dist_same_un", "14"); editor.putString("mfcc_dist_diff_un", "24"); } // other devices else { editor.putString("mfcc_dist_same_semi", "15.6"); editor.putString("mfcc_dist_diff_semi", "21.6"); editor.putString("mfcc_dist_same_un", "15.6"); editor.putString("mfcc_dist_diff_un", "21.6"); Toast.makeText(this, "Your device is not recognized and the result might not be accurate...", Toast.LENGTH_SHORT).show(); } Log.i("Crowd++", "First time launched"); AlertDialog dialog = new AlertDialog.Builder(this).create(); dialog.setTitle("Welcome to Crowd++"); dialog.setMessage(Constants.hello_msg); dialog.setButton(AlertDialog.BUTTON_POSITIVE, "Close", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }); dialog.show(); dialog.getButton(DialogInterface.BUTTON_POSITIVE).setTextSize(20); } editor.putInt("count", ++ct); editor.commit(); Log.i("Launched Count", Integer.toString(ct)); mConst = new Constants(this); if (!Constants.calibration()) Toast.makeText(this, "You haven't calibrated the system.", Toast.LENGTH_SHORT).show(); }
From source file:com.cypress.cysmart.CommonFragments.NavigationDrawerFragment.java
/** * Users of this fragment must call this method to set up the navigation * drawer interactions./*from w w w . j ava 2s . co m*/ * * @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); ActionBar actionBar = getActivity().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_launcher, /* NavigationDrawer 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; } getActivity().invalidateOptionsMenu(); // calls // onPrepareOptionsMenu() } }; // 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.kosbrother.houseprice.ActionBarTabs.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.action_bar_tabs); ActionBar actionBar = getActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); // actionBar.setDisplayShowTitleEnabled(false); if (Build.VERSION.SDK_INT >= 14) { actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setHomeButtonEnabled(true); }// w w w . j av a 2 s. c o m actionBar.addTab(actionBar.newTab().setText("") .setTabListener(new TabListener("http://m.yungching.com.tw/", "YungChing"))); actionBar.addTab(actionBar.newTab().setText("") .setTabListener(new TabListener("http://m.sinyi.com.tw/", "SinYi"))); actionBar.addTab(actionBar.newTab().setText("591") .setTabListener(new TabListener("http://m.591.com.tw/mobile-index.html?f=app", "591"))); CallAds(); }
From source file:com.sintef_energy.ubisolar.fragments.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 ww .ja va2s . co m 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.pld.h4414.sportify.ViewPagerActivity.java
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_view_pager); // 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 buttonProfile should not be enabled, since there is no hierarchical // parent./*from w ww . j av a 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().setIcon(mAppSectionsPagerAdapter.getPageIcon(i)).setTabListener(this)); } /* That will be used for v2 or next FloatingActionButton fabButton = new FloatingActionButton.Builder(this) .withDrawable(getResources().getDrawable(R.drawable.ic_add)) .withButtonColor(Color.WHITE) .withGravity(Gravity.BOTTOM | Gravity.RIGHT) .withMargins(0, 0, 16, 16) .create(); */ }
From source file:tn.codeit.darna.MainActivity.java
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // fragmentManager = getSupportFragmentManager(); // 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(); // ColorDrawable colorDrawable = new ColorDrawable(Color.parseColor("#2962FF")); //actionBar.setBackgroundDrawable(colorDrawable); // Specify that the Home/Up button should not be enabled, since there is no hierarchical // parent./*w w w .j a v a2 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. // 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("Accueil").setTabListener(this)); actionBar.addTab(actionBar.newTab().setText("Map").setTabListener(this)); actionBar.addTab(actionBar.newTab().setText("Filtrer").setTabListener(this)); actionBar.addTab(actionBar.newTab().setText("Publier") .setTabListener(this)); makeActionOverflowMenuShown(); }
From source file:com.filepager.afilechooser.FileChooserActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { ActionBar actionBar = getActionBar(); if (HAS_ACTIONBAR) { boolean hasBackStack = mFragmentManager.getBackStackEntryCount() > 0; actionBar.setDisplayHomeAsUpEnabled(hasBackStack); actionBar.setHomeButtonEnabled(hasBackStack); }/*from w w w. j a v a 2s . com*/ getMenuInflater().inflate(R.menu.file_manager_activity, menu); return true; }
From source file:com.decad3nce.aegis.AegisActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mViewPager = new ViewPager(this); mViewPager.setId(R.id.pager);/*from w w w . j a v a 2 s . co m*/ setContentView(mViewPager); final ActionBar bar = getActionBar(); bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); bar.setDisplayOptions(ActionBar.DISPLAY_SHOW_TITLE, ActionBar.DISPLAY_SHOW_TITLE); bar.setDisplayShowHomeEnabled(true); bar.setHomeButtonEnabled(true); bar.setTitle(R.string.app_name); mTabsAdapter = new TabsAdapter(this, mViewPager); mTabsAdapter.addTab(bar.newTab().setText(R.string.alarm_section), SMSAlarmFragment.class, null); mTabsAdapter.addTab(bar.newTab().setText(R.string.lock_section), SMSLockFragment.class, null); mTabsAdapter.addTab(bar.newTab().setText(R.string.wipe_section), SMSWipeFragment.class, null); mTabsAdapter.addTab(bar.newTab().setText(R.string.locate_section), SMSLocateFragment.class, null); if (savedInstanceState != null) { bar.setSelectedNavigationItem(savedInstanceState.getInt("tab", 0)); } final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this); alarmEnabled = preferences.getBoolean(PREFERENCES_ALARM_ENABLED, this.getResources().getBoolean(R.bool.config_default_alarm_enabled)); wipeEnabled = preferences.getBoolean(PREFERENCES_WIPE_ENABLED, this.getResources().getBoolean(R.bool.config_default_wipe_enabled)); lockEnabled = preferences.getBoolean(PREFERENCES_LOCK_ENABLED, this.getResources().getBoolean(R.bool.config_default_lock_enabled)); locateEnabled = preferences.getBoolean(PREFERENCES_LOCATE_ENABLED, this.getResources().getBoolean(R.bool.config_default_locate_enabled)); invalidateOptionsMenu(); mDevicePolicyManager = (DevicePolicyManager) getSystemService(Context.DEVICE_POLICY_SERVICE); }