List of usage examples for android.app ActionBar setDisplayHomeAsUpEnabled
public abstract void setDisplayHomeAsUpEnabled(boolean showHomeAsUp);
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;/*from w ww .j av a 2s . co 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:com.bishalniroj.loadsheddingreminder.TabbedViewScheduleActivity.java
public void onCreate(Bundle savedInstanceState) { int currentItem = -1; super.onCreate(savedInstanceState); mActivity = this; setContentView(R.layout.activity_collection_demo); mGroupListPagerAdapter = new GroupListPagerAdapter(getSupportFragmentManager()); // Set up action bar. final ActionBar actionBar = getActionBar(); // Specify that the Home button should show an "Up" caret, indicating that touching the // button will take the user one step up in the application's hierarchy. actionBar.setDisplayHomeAsUpEnabled(true); //// ww w .jav a 2 s .c o m SharedPreferences sharedPref = getSharedPreferences(Utilities.SHARED_PREFERENCES, Context.MODE_PRIVATE); mPrefEditor = sharedPref.edit(); // Set up the ViewPager, attaching the adapter. mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setAdapter(mGroupListPagerAdapter); currentItem = sharedPref.getInt(Utilities.SHARED_PREFERENCES_TAB_NUMBER, -1); Utilities.Logd("currentItem = " + currentItem); currentItem = currentItem == -1 ? 0 : currentItem; mViewPager.setCurrentItem(currentItem); //DATABASE mScheduleDbHelper = LoadSheddingScheduleDbHelper.GetInstance(this, false); mScheduleDbHelper.open(); }
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 w w . j a v a 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); }
From source file:at.florian_lentsch.expirysync.EditProductActivity.java
/** * Set up the {@link android.app.ActionBar}, if the API is available. *//* w ww . j a va2s .com*/ @TargetApi(Build.VERSION_CODES.HONEYCOMB) private void setupActionBar() { ActionBar actionBar = null; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB && (actionBar = getActionBar()) != null) { // TODO: Find out, why this is not being done for android 4 for example: actionBar.setDisplayHomeAsUpEnabled(true); } }
From source file:com.dictionary.activity.ArticleCollectionActivity.java
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); final Application app = (Application) getApplication(); app.installTheme(this); requestWindowFeature(Window.FEATURE_PROGRESS); setContentView(R.layout.activity_article_collection_loading); app.push(this); final ActionBar actionBar = getActionBar(); actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setSubtitle("..."); final Intent intent = getIntent(); final int position = intent.getIntExtra("position", 0); AsyncTask<Void, Void, ArticleCollectionPagerAdapter> createAdapterTask = new AsyncTask<Void, Void, ArticleCollectionPagerAdapter>() { @Override/*from w ww .j a va2 s .c om*/ protected ArticleCollectionPagerAdapter doInBackground(Void... params) { ArticleCollectionPagerAdapter result; Uri articleUrl = intent.getData(); if (articleUrl != null) { result = createFromUri(app, articleUrl); } else { String action = intent.getAction(); if (action == null) { result = createFromLastResult(app); } else if (action.equals("showRandom")) { result = createFromRandom(app); } else if (action.equals("showBookmarks")) { result = createFromBookmarks(app); } else if (action.equals("showHistory")) { result = createFromHistory(app); } else { result = createFromIntent(app, intent); } } return result; } @Override protected void onPostExecute(ArticleCollectionPagerAdapter adapter) { if (isFinishing() || onDestroyCalled) { return; } articleCollectionPagerAdapter = adapter; if (articleCollectionPagerAdapter == null || articleCollectionPagerAdapter.getCount() == 0) { int messageId; if (articleCollectionPagerAdapter == null) { messageId = R.string.article_collection_invalid_link; } else { messageId = R.string.article_collection_nothing_found; } Toast.makeText(ArticleCollectionActivity.this, messageId, Toast.LENGTH_SHORT).show(); finish(); return; } if (position > articleCollectionPagerAdapter.getCount() - 1) { Toast.makeText(ArticleCollectionActivity.this, R.string.article_collection_selected_not_available, Toast.LENGTH_SHORT).show(); finish(); return; } setContentView(R.layout.activity_article_collection); findViewById(R.id.pager_title_strip).setVisibility( articleCollectionPagerAdapter.getCount() == 1 ? ViewGroup.GONE : ViewGroup.VISIBLE); viewPager = (ViewPager) findViewById(R.id.pager); viewPager.setAdapter(articleCollectionPagerAdapter); viewPager.setOnPageChangeListener(new OnPageChangeListener() { @Override public void onPageScrollStateChanged(int arg0) { } @Override public void onPageScrolled(int arg0, float arg1, int arg2) { } @Override public void onPageSelected(final int position) { updateTitle(position); runOnUiThread(new Runnable() { @Override public void run() { ArticleFragment fragment = (ArticleFragment) articleCollectionPagerAdapter .getItem(position); fragment.applyTextZoomPref(); } }); } }); viewPager.setCurrentItem(position); PagerTitleStrip titleStrip = (PagerTitleStrip) findViewById(R.id.pager_title_strip); titleStrip.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 10); updateTitle(position); articleCollectionPagerAdapter.registerDataSetObserver(new DataSetObserver() { @Override public void onChanged() { if (articleCollectionPagerAdapter.getCount() == 0) { finish(); } } }); } }; createAdapterTask.execute(); }
From source file:cz.urbangaming.galgs.GAlg.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); ActionBar actionBar = getActionBar(); actionBar.setDisplayHomeAsUpEnabled(false); actionBar.setDisplayShowTitleEnabled(false); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST); ArrayList<String> itemList = new ArrayList<String>(); //TODO:Make static, use String constants strings.xml itemList.add(getResources().getString(R.string.workmode_add)); itemList.add(getResources().getString(R.string.workmode_edit)); itemList.add(getResources().getString(R.string.workmode_delete)); this.aAdpt = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, android.R.id.text1, itemList);//from w w w . j a va 2 s . com actionBar.setListNavigationCallbacks(aAdpt, this); mGLSurfaceView = new GLSurfaceView(this); if (detectOpenGLES20()) { // Tell the surface view we want to create an OpenGL ES 2.0-compatible // context, and set an OpenGL ES 2.0-compatible renderer. mGLSurfaceView.setEGLContextClientVersion(2); pointsRenderer = new PointsRenderer(this); mGLSurfaceView.setRenderer(pointsRenderer); } else { // TODO: Handle as an unrecoverable error and leave the activity somehow... } // External files preparation InputStream in = null; OutputStream out = null; try { Log.d(DEBUG_TAG, "Media rady: " + isExternalStorageWritable()); AssetManager assetManager = getAssets(); in = assetManager.open(GALGS_CLASS_FILE); if (in != null) { galgsRubyClassesDirectory = new File(GALGS_CLASS_DIR); galgsRubyClassesDirectory.mkdir(); if (!galgsRubyClassesDirectory.isDirectory()) { Log.d(DEBUG_TAG, "Hmm, " + galgsRubyClassesDirectory + " does not exist, trying mkdirs..."); galgsRubyClassesDirectory.mkdirs(); } File outputFile = new File(galgsRubyClassesDirectory, GALGS_CLASS_FILE); if (outputFile.exists()) { // Load from what user might have edited outputFile = new File(galgsRubyClassesDirectory, GALGS_CLASS_FILE + ".orig"); } out = new FileOutputStream(outputFile); copyFile(in, out); in.close(); in = null; out.flush(); out.close(); out = null; } else { Log.e("IO HELL", "Asset " + GALGS_CLASS_FILE + " not found..."); } } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } // Stops the thing from trashing the context on pause/resume. mGLSurfaceView.setPreserveEGLContextOnPause(true); setContentView(mGLSurfaceView); }
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); }//w w w . j av a 2 s. c o m getMenuInflater().inflate(R.menu.file_manager_activity, menu); return true; }
From source file:com.otaupdater.SettingsActivity.java
@Override @SuppressWarnings("deprecation") public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); final ActionBar bar = getActionBar(); if (bar != null) { bar.setDisplayHomeAsUpEnabled(true); }/* w w w . j a v a2 s . c om*/ cfg = Config.getInstance(getApplicationContext()); addPreferencesFromResource(R.xml.settings); accountPref = findPreference("account_pref"); if (cfg.isUserLoggedIn()) { accountPref.setSummary(getString(R.string.settings_account_summary_loggedin, cfg.getUsername())); } else { accountPref.setSummary(R.string.settings_account_summary); } notifPref = (CheckBoxPreference) findPreference("notif_pref"); notifPref.setChecked(cfg.getShowNotif()); wifidlPref = (CheckBoxPreference) findPreference("wifidl_pref"); wifidlPref.setChecked(cfg.getWifiOnlyDl()); autodlPref = (CheckBoxPreference) findPreference("autodl_pref"); autodlPref.setChecked(cfg.getAutoDlState()); prokeyPref = findPreference("prokey_pref"); if (cfg.hasProKey()) { prokeyPref.setTitle(R.string.settings_prokey_title_pro); } updateProKeySummary(); resetWarnPref = findPreference("resetwarn_pref"); donatePref = findPreference("donate_pref"); bindService(new Intent("com.android.vending.billing.InAppBillingService.BIND"), serviceConn, Context.BIND_AUTO_CREATE); if (EXTRA_SHOW_GET_PROKEY_DLG.equals(getIntent().getAction())) { showGetProKeyDialog(); } if (EXTRA_SHOW_ACCOUNT_DLG.equals(getIntent().getAction())) { showAccountDialog(); } }
From source file:org.jorge.lolin1.ui.activities.ChampionDetailFragmentActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); if (!preferences.getBoolean("showcase_champion_detail_done", Boolean.FALSE)) setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); selectedChampion = getIntent().getParcelableExtra(SELECTED_CHAMPION); super.onCreate(savedInstanceState); setContentView(R.layout.activity_champion_detail); ActionBar actionBar; assert getActionBar() != null; if (findViewById(R.id.champion_title) != null) { //Portrait layout if (!(actionBar = getActionBar()).isShowing()) { actionBar.show();/* w w w . j a v a 2s . c o m*/ } actionBar.setDisplayHomeAsUpEnabled(Boolean.TRUE); ((TextView) findViewById(R.id.champion_name)).setText(selectedChampion.getName()); ((TextView) findViewById(R.id.champion_title)).setText(selectedChampion.getTitle()); initChampionInfoPager(); if (!preferences.getBoolean("showcase_champion_detail_done", Boolean.FALSE)) detailShowcase = new ShowcaseView.Builder(this).setContentText(R.string.tutorial_detail_contents) .setContentTitle(R.string.tutorial_detail_title) .setStyle(R.style.CustomShowcaseThemePlusNoButton) .setTarget(new ViewTarget(R.id.champion_detail_pager, this)).build(); ChampionDetailFragmentActivity.this.runOnUiThread(new Runnable() { @Override public void run() { ((ImageView) findViewById(R.id.champion_bust)) .setImageDrawable(new BitmapDrawable(getResources(), ChampionManager.getInstance() .getBustImageByChampion(200, 200, selectedChampion, getApplicationContext()))); } }); } else { //Landscape layout if ((actionBar = getActionBar()).isShowing()) { actionBar.hide(); } skinsViewPager = ((ViewPager) findViewById(R.id.skins_view_pager)); initChampionSkinsPager(); } }
From source file:cz.zcu.kiv.eeg.mobile.base.ui.NavigationActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.base);/*from w w w . j a v a 2 s . co m*/ SharedPreferences credentials = getSharedPreferences(Values.PREFS_CREDENTIALS, Context.MODE_PRIVATE); username = credentials.getString("username", null); password = credentials.getString("password", null); SYNC_URL = credentials.getString("url", null); db = new CBDatabase(Keys.DB_NAME, NavigationActivity.this); startSync(); db = new CBDatabase(Keys.DB_NAME, NavigationActivity.this); UserProfile logged_up = db.fetchUserProfileData(); String loggedUserId = logged_up.getUserId(); String loggedUserName = logged_up.getUserName(); // String getDefaultResgrpId = db.fetchDefaultResearchGroup(getLoggedUserId); SharedPreferences tempData = getSharedPreferences(Values.PREFS_TEMP, Context.MODE_PRIVATE); SharedPreferences.Editor editor = tempData.edit(); if (loggedUserId == null) { Toast.makeText(NavigationActivity.this, "Error in pulling user profile data", Toast.LENGTH_LONG).show(); } else { Toast.makeText(NavigationActivity.this, "user id= " + loggedUserId + " userName=" + loggedUserName, Toast.LENGTH_LONG).show(); editor.putString("loggedUserDocID", loggedUserId); editor.putString("loggedUserName", loggedUserName); editor.commit(); } // if(getDefaultResgrpId==null){ // Toast.makeText(NavigationActivity.this,"Error in pulling def res grp",Toast.LENGTH_LONG).show(); // }else{ // Toast.makeText(NavigationActivity.this,"def res grp id= "+getDefaultResgrpId,Toast.LENGTH_LONG).show(); // editor.putString("loggedUserDefGrpID", getDefaultResgrpId); // editor.commit(); // } Database database = db.getDatabase(); Toast.makeText(NavigationActivity.this, "doc count= " + database.getDocumentCount(), Toast.LENGTH_LONG) .show(); final ActionBar actionBar = getActionBar(); actionBar.setHomeButtonEnabled(true); actionBar.setDisplayHomeAsUpEnabled(true); // Locate DrawerLayout in drawer_main.xml drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); drawerList = (ListView) findViewById(R.id.left_drawer); ListAdapter drawerAdapter = new MenuAdapter(actionBar.getThemedContext(), R.layout.base_menu_row, getResources().getStringArray(R.array.sections_list_icons), getResources().getStringArray(R.array.sections_list)); drawerList.setAdapter(drawerAdapter); drawerList.setOnItemClickListener(this); // ActionBarDrawerToggle ties together the the proper interactions // between the sliding drawer and the action bar app icon drawerToggle = new ActionBarDrawerToggle(this, drawerLayout, R.drawable.ic_navigation_drawer, R.string.nav_open, R.string.nav_close) { public void onDrawerClosed(View view) { super.onDrawerClosed(view); } public void onDrawerOpened(View drawerView) { super.onDrawerOpened(drawerView); } }; drawerLayout.setDrawerListener(drawerToggle); if (savedInstanceState == null) { openSection(0); } if (savedInstanceState != null) { previousFragment = savedInstanceState.getInt("previousFragment", 0); } }