List of usage examples for android.app ActionBar setDisplayShowHomeEnabled
public abstract void setDisplayShowHomeEnabled(boolean showHome);
From source file:com.keithcassidy.finishline.HomeActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_home); //volume controls will adjust media playback when this app has focus setVolumeControlStream(AudioManager.STREAM_MUSIC); // Set up the action bar. final ActionBar actionBar = getActionBar();// getSupportActionBar(); actionBar.setDisplayShowHomeEnabled(true); actionBar.setDisplayShowTitleEnabled(true); actionBar.setBackgroundDrawable(getResources().getDrawable(R.drawable.pinstripe_actionbar_tile)); currentFragment = PreferencesUtils.getCurrentFragment(this); homeFragment = new HomeFragment(); setupFragment1 = new SetupFragment(); ((SetupFragment) setupFragment1).setBuoyNumber(1); setupFragment2 = new SetupFragment(); ((SetupFragment) setupFragment2).setBuoyNumber(2); lineCrossFragment = new LineCrossingsFragment(); mapFragment = new FinishLineMapFragment(); // Create the adapter that will return a fragment for each of the // primary sections of the app. mSectionsPagerAdapter = new SectionsPagerAdapter(getFragmentManager()); // Set up the ViewPager with the sections adapter. mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setAdapter(mSectionsPagerAdapter); mViewPager.setCurrentItem(currentFragment); mIndicator = (TitlePageIndicator) findViewById(R.id.indicator); mIndicator.setViewPager(mViewPager); mIndicator.setClipPadding(-10);//from w w w . ja va 2s .c o m // 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. mIndicator.setOnPageChangeListener(new ViewPager.OnPageChangeListener() { @Override public void onPageSelected(int position) { try { currentFragment = position; // PreferencesUtils.setCurrentFragment(context, currentFragment); TabFocusInterface frag = (TabFocusInterface) mSectionsPagerAdapter.getItem(position); frag.tabSetFocus(); if (lastPosition != -1) { frag = (TabFocusInterface) mSectionsPagerAdapter.getItem(lastPosition); frag.tabLoseFocus(); } lastPosition = position; } catch (Exception e) { Log.e(TAG, "onPageSelected " + e); } } @Override public void onPageScrollStateChanged(int state) { } @Override public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { } }); LocalBroadcastManager.getInstance(this).registerReceiver(onBroadcastServiceStatusReceived, new IntentFilter(Constants.SERVICE_STATUS_MESSAGE)); new SimpleEula(this).show(); }
From source file:org.webinos.android.app.wrt.ui.WidgetListActivity.java
@Override public void onCreate(Bundle bundle) { super.onCreate(bundle); setContentView(R.layout.activity_widget_list); ActionBar actionBar = getActionBar(); if (actionBar != null) { actionBar.setDisplayShowHomeEnabled(false); actionBar.setDisplayShowTitleEnabled(false); } else {// w ww.ja v a2 s.co m Log.i(TAG, "WidgetListActivity has no action bar."); } registerForContextMenu(getListView()); asyncRefreshHandler = new Handler() { @Override public void handleMessage(Message msg) { initList(); } }; mgr = WidgetManagerService.getWidgetManagerInstance(this, this); if (mgr != null) { mgr.addEventListener(this); initList(); } scanner = new WidgetImportHelper(this); /* populate stores array */ stores = getStores(); synchronized (this) { if (mgr == null) { blocked = true; runOnUiThread(new Runnable() { @Override public void run() { /* put up progress dialog until the service is * available */ Activity context = WidgetListActivity.this; progressDialog = new ProgressDialog(context); progressDialog.setCancelable(false); progressDialog.setMessage(context.getString(R.string.initialising_runtime)); progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); progressDialog.setIndeterminate(false); progressDialog.setMax(PROGRESS_MAX); progressDialog.show(); progressDialog.setProgressNumberFormat(null); } }); } } /* BroadcastReceiver to receive module loading progress */ progressBroadcastReceiver = new ProgressBroadcastReceiver(); }
From source file:edu.pdx.cecs.orcycle.TabsConfig.java
@Override public void onTabSelected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) { try {//from ww w . j a v a 2s. co m // When the given tab is selected, switch to the corresponding page in // the ViewPager. // Toast.makeText(this, "TabSelected", Toast.LENGTH_LONG).show(); mViewPager.setCurrentItem(tab.getPosition()); final ActionBar actionBar = getActionBar(); switch (tab.getPosition()) { case 0: actionBar.setDisplayShowTitleEnabled(false); actionBar.setDisplayShowHomeEnabled(false); break; case 1: actionBar.setDisplayShowTitleEnabled(true); actionBar.setDisplayShowHomeEnabled(true); actionBar.setTitle(R.string.app_name); break; case 2: actionBar.setDisplayShowTitleEnabled(true); actionBar.setDisplayShowHomeEnabled(true); actionBar.setTitle(R.string.app_name); break; case 3: actionBar.setDisplayShowTitleEnabled(true); actionBar.setDisplayShowHomeEnabled(true); actionBar.setTitle(R.string.app_name); break; } } catch (Exception ex) { Log.e(MODULE_TAG, ex.getMessage()); } }
From source file:com.jiusg.mainscreenshow.ui.MSS.java
/** * ActionBar//from w w w . j ava 2 s. co m * * @param layoutId Id */ public void setActionBarLayout(int layoutId) { ActionBar actionBar = getActionBar(); if (null != actionBar) { actionBar.setDisplayShowHomeEnabled(false); actionBar.setDisplayShowCustomEnabled(true); actionBar.setDisplayShowTitleEnabled(false); actionBar.setDisplayHomeAsUpEnabled(false); actionBar.setDisplayUseLogoEnabled(false); LayoutInflater inflator = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE); View v = inflator.inflate(layoutId, null); ActionBar.LayoutParams layout = new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); actionBar.setCustomView(v, layout); } }
From source file:com.scto.filerenamer.FileRenamerActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mSettings = Prefs.getSharedPreferences(this); mSettings.registerOnSharedPreferenceChangeListener(this); if (Prefs.getThemeType(this) == false) { mThemeId = R.style.AppTheme_Light; setTheme(mThemeId);/* www. ja v a 2 s . c o m*/ } else { mThemeId = R.style.AppTheme_Dark; setTheme(mThemeId); } ActionBar mActionBar = getActionBar(); if (mActionBar != null) { mActionBar.setDisplayHomeAsUpEnabled(true); mActionBar.setDisplayShowHomeEnabled(true); mActionBar.setDisplayShowTitleEnabled(true); mActionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); } else { if (BuildConfig.DEBUG) { Log.w("[" + TAG + "]", "mActionBar == null"); } } setContentView(R.layout.fragment_tabs_pager); mTabHost = (TabHost) findViewById(android.R.id.tabhost); mTabHost.setup(); mViewPager = (ViewPager) findViewById(R.id.pager); mTabsAdapter = new TabsAdapter(this, mTabHost, mViewPager); mTabsAdapter.addTab( mTabHost.newTabSpec(getString(R.string.addNumber)).setIndicator(getString(R.string.addNumber)), AddNumbersFragment.class, null); mTabsAdapter.addTab( mTabHost.newTabSpec(getString(R.string.addCustom)).setIndicator(getString(R.string.addCustom)), AddCustomFragment.class, null); mTabsAdapter.addTab( mTabHost.newTabSpec(getString(R.string.addDate)).setIndicator(getString(R.string.addDate)), AddCharsFragment.class, null); mTabsAdapter.addTab(mTabHost.newTabSpec(getString(R.string.findAndReplace)) .setIndicator(getString(R.string.findAndReplace)), AddDateFragment.class, null); mTabsAdapter.addTab( mTabHost.newTabSpec(getString(R.string.removeChars)).setIndicator(getString(R.string.removeChars)), RemoveCharsFragment.class, null); Bundle extras = getIntent().getExtras(); if (extras != null) { this.setTitle(extras.getString("dir") + " :: " + getString(R.string.app_name)); } else { if (BuildConfig.DEBUG) { Log.w("[" + TAG + "]", "onCreate( savedInstanceState ) : extras == null"); } this.setTitle(" :: " + getString(R.string.app_name)); } if (savedInstanceState != null) { mActionBar.setSelectedNavigationItem(savedInstanceState.getInt("action_bar_tab", 0)); mTabHost.setCurrentTabByTag(savedInstanceState.getString("tab_host")); } }
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 www. ja v a 2 s .c o 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); }
From source file:ch.ethz.coss.nervousnet.hub.ui.SensorDisplayActivity.java
@Override public void updateActionBar() { getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); LayoutInflater inflator = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE); View v = inflator.inflate(R.layout.ab_nn, null); ActionBar actionBar; Switch mainSwitch;/*w ww. j av a 2 s. c o m*/ actionBar = getActionBar(); actionBar.setDisplayHomeAsUpEnabled(false); actionBar.setDisplayShowHomeEnabled(false); actionBar.setDisplayShowCustomEnabled(true); actionBar.setDisplayShowTitleEnabled(false); actionBar.setCustomView(v); mainSwitch = (Switch) findViewById(R.id.mainSwitch); byte state = ((Application) getApplication()).getState(); NNLog.d("SensorDisplayActivity", "state = " + state); mainSwitch.setChecked(state == 0 ? false : true); mainSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { startStopSensorService(isChecked); } }); }
From source file:htw.bui.openreskit.discard.InspectionActivity.java
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mOverlayFramelayout = new FrameLayout(this); setContentView(mOverlayFramelayout); View view = getLayoutInflater().inflate(R.layout.inspection_fragment, mOverlayFramelayout, false); mOverlayFramelayout.addView(view);/*from w ww . j ava 2 s . co m*/ mContext = this; mPrefs = PreferenceManager.getDefaultSharedPreferences(mContext); mHelpView = getLayoutInflater().inflate(R.layout.help_overlay, mOverlayFramelayout, false); mInspFrag = (InspectionFragment) mFragMan.findFragmentById(R.id.inspection_fragment); mAddInspectionButton = (Button) mOverlayFramelayout.findViewById(R.id.addInspectionButton); mAddInspectionButton.setOnClickListener(mButtonListener); if (Utils.isTablet(this)) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE); if (findViewById(R.id.inspectionLayoutContainer) != null) { // if we are being restored from a previous state, then we dont need to do anything and should // return or else we could end up with overlapping fragments. if (savedInstanceState != null) return; // Create an instance of inspectionInfoFragment mInspectionInfoFragment = new InspectionInfoFragment(); // Create an instance of RunningInspectionFragment mRunningInspectionFragment = new RunningInspectionFragment(); // add fragment to the fragment container layout FragmentTransaction ft = mFragMan.beginTransaction(); ft.add(R.id.inspectionFrameLayout, mInspectionInfoFragment); ft.hide(mInspectionInfoFragment).commit(); FragmentTransaction ft1 = mFragMan.beginTransaction(); ft1.add(R.id.inspectionFrameLayout, mRunningInspectionFragment); ft1.hide(mRunningInspectionFragment).commit(); } } else { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT); } ActionBar bar = getActionBar(); bar.setDisplayOptions( ActionBar.DISPLAY_SHOW_CUSTOM | ActionBar.DISPLAY_USE_LOGO | ActionBar.DISPLAY_SHOW_TITLE); bar.setDisplayShowHomeEnabled(true); }
From source file:com.commonsware.cwac.cam2.support.CameraFragment.java
@Override public void onHiddenChanged(boolean isHidden) { super.onHiddenChanged(isHidden); if (!isHidden) { ActionBar ab = getActivity().getActionBar(); ab.setBackgroundDrawable(/*from ww w. ja v a2s .co m*/ getActivity().getResources().getDrawable(R.drawable.cwac_cam2_action_bar_bg_transparent)); ab.setTitle(""); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { ab.setDisplayHomeAsUpEnabled(false); } else { ab.setDisplayShowHomeEnabled(false); ab.setHomeButtonEnabled(false); } } }
From source file:com.commonsware.cwac.cam2.support.ConfirmationFragment.java
@Override public void onHiddenChanged(boolean isHidden) { super.onHiddenChanged(isHidden); if (!isHidden) { ActionBar ab = getActivity().getActionBar(); ab.setBackgroundDrawable(//from w w w. jav a 2 s . c o m getActivity().getResources().getDrawable(R.drawable.cwac_cam2_action_bar_bg_translucent)); ab.setTitle(""); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { ab.setDisplayHomeAsUpEnabled(true); ab.setHomeAsUpIndicator(R.drawable.cwac_cam2_ic_close_white); } else { ab.setIcon(R.drawable.cwac_cam2_ic_close_white); ab.setDisplayShowHomeEnabled(true); ab.setHomeButtonEnabled(true); } } }