List of usage examples for android.app ActionBar setDisplayHomeAsUpEnabled
public abstract void setDisplayHomeAsUpEnabled(boolean showHomeAsUp);
From source file:org.ounl.lifelonglearninghub.learntracker.gis.ou.db.charts.PieChartActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.piechart);//from ww w .ja v a 2 s . c o m final ActionBar actionBar = getActionBar(); actionBar.setDisplayHomeAsUpEnabled(true); populateChart(); applySize(); renderer.setApplyBackgroundColor(true); //mRenderer.setBackgroundColor(Color.argb(100, 50, 50, 50)); renderer.setBackgroundColor(Color.WHITE); //renderer.setChartTitleTextSize(50f); renderer.setChartTitle("Overall distribution of time by assignment"); //renderer.setLabelsTextSize(30f); renderer.setLabelsColor(Color.BLACK); //renderer.setLegendTextSize(30f); renderer.setMargins(new int[] { 20, 30, 15, 0 }); renderer.setZoomButtonsVisible(true); renderer.setStartAngle(90); // Retrieve values from database HashMap<Integer, Long> hmIL = Session.getSingleInstance().getDatabaseHandler().getSubjectsAccumulated(); List<ActivitySession> las = Session.getSingleInstance().getActivities(); NAME_LIST = new String[las.size()]; VALUES = new double[las.size()]; int iNumRecords = 0; for (int i = 0; i < las.size(); i++) { Long LAccum = hmIL.get(new Integer(i)); if (LAccum == null) { LAccum = 0L; } if (LAccum > 0) { NAME_LIST[i] = las.get(i).getSubject_task_desc(); VALUES[i] = LAccum.longValue(); mSeries.add(NAME_LIST[i], VALUES[i]); SimpleSeriesRenderer ssr = new SimpleSeriesRenderer(); ssr.setColor(COLORS[(mSeries.getItemCount() - 1) % COLORS.length]); renderer.addSeriesRenderer(ssr); Log.d(CLASSNAME, i + " estimated " + NAME_LIST[i] + " / accomplished " + VALUES[i]); iNumRecords++; } } if (iNumRecords == 0) { Toast.makeText(PieChartActivity.this, "The pie chart is empty because you have not recorded any activity yet.", Toast.LENGTH_LONG) .show(); } if (mChartView != null) { mChartView.repaint(); } }
From source file:com.example.kaow.caltest.UserInfo.java
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_user_info); // Create the adapter that will return a fragment for each of the three primary sections // of the app. mAppSectionsPagerAdapter = new AppSectionsPagerAdapter(getSupportFragmentManager()); 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); // Set up the ViewPager, attaching the adapter and setting up a listener for when the // user swipes between sections. actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setAdapter(mAppSectionsPagerAdapter); mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override//from w ww . j a va2s . 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 < uInfoTitles.length; i++) { actionBar.addTab(actionBar.newTab().setText(uInfoTitles[i]).setTabListener(this)); } }
From source file:com.veggies.android.todoList.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); menuTexts = new String[] { "All Lists", "Default", "Personal", "Shopping", "Wishlist", "Work", "Unfinished" }; dropdownMenuItemList.add(new DropdownMenuItem(R.drawable.ic_list_white_24dp, menuTexts[0])); dropdownMenuItemList.add(new DropdownMenuItem(R.drawable.ic_list_white_24dp, menuTexts[1])); dropdownMenuItemList.add(new DropdownMenuItem(R.drawable.ic_person_pin_white_24dp, menuTexts[2])); dropdownMenuItemList.add(new DropdownMenuItem(R.drawable.ic_local_grocery_store_white_24dp, menuTexts[3])); dropdownMenuItemList.add(new DropdownMenuItem(R.drawable.ic_favorite_white_24dp, menuTexts[4])); dropdownMenuItemList.add(new DropdownMenuItem(R.drawable.ic_card_travel_white_24dp, menuTexts[5])); dropdownMenuItemList.add(new DropdownMenuItem(R.drawable.ic_highlight_off_white_24dp, menuTexts[6])); spinnerAdapter = new DropdownMenuItemAdapter(this, dropdownMenuItemList); //get the email passed by login UI Intent intent = this.getIntent(); mEmail = intent.getStringExtra(EMAIL); mTitle = mDrawerTitle = getTitle();//from w w w .ja v a 2 s . c o m //put the drawer items in a hash map, so we can just use it to lookup index mDrawerItems = new HashMap<>(); String[] drawerArray = getResources().getStringArray(R.array.drawer_array); for (int i = 0; i < drawerArray.length; i++) { mDrawerItems.put(drawerArray[i], i); } drawerItemList.add(new DrawerItem(R.drawable.ic_list_white_24dp, "Todo List")); drawerItemList.add(new DrawerItem(R.drawable.ic_settings_white_24dp, "Setting")); BaseAdapter adapter = new DrawerItemAdapter(this, drawerItemList); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerList = (ListView) findViewById(R.id.left_drawer); // 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 mDrawerList.setAdapter(adapter); mDrawerList.setOnItemClickListener(new DrawerItemClickListener()); // enable ActionBar app icon to behave as action to toggle nav drawer ActionBar actionbar = getActionBar(); actionbar.setDisplayHomeAsUpEnabled(true); actionbar.setHomeButtonEnabled(true); getActionBar().setIcon(R.drawable.logo_white); ColorDrawable colorDrawable = new ColorDrawable(); colorDrawable.setColor(0xff303F9F); getActionBar().setBackgroundDrawable(colorDrawable); // ActionBarDrawerToggle ties together the the proper interactions // between the sliding drawer and the action bar app icon mDrawerToggle = new ActionBarDrawerToggle(this, /* host Activity */ mDrawerLayout, /* DrawerLayout object */ R.drawable.ic_drawer, /* nav drawer image to replace 'Up' caret */ R.string.drawer_open, /* "open drawer" description for accessibility */ R.string.drawer_close /* "close drawer" description for accessibility */ ) { public void onDrawerClosed(View view) { getActionBar().setTitle(mTitle); if (listFragmentFlag) { setActionMenu(); } invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu() } public void onDrawerOpened(View drawerView) { getActionBar().setTitle(mDrawerTitle); hideActionMenu(); invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu() } }; mDrawerLayout.setDrawerListener(mDrawerToggle); if (savedInstanceState == null) { selectItem(0); } }
From source file:c.neo.placas_validator.LicenseDataActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case android.R.id.home: Log.d(TAG, "HOME BUTTON SELECTED"); ActionBar actionBar = getActionBar(); actionBar.setDisplayHomeAsUpEnabled(false); // app icon in action bar clicked; go home Intent intent = new Intent(this, MainActivity.class); intent.putExtra("PLACA_NO", licenseID); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(intent);//from ww w. j av a 2 s. co m //slidingPaneLayout.openPane(); return true; default: return super.onOptionsItemSelected(item); } }
From source file:org.amahi.anywhere.activity.ServerActivity.java
private void setUpHomeNavigation() { ActionBar actionBar = getActionBar(); actionBar.setHomeButtonEnabled(isNavigationDrawerAvailable()); actionBar.setDisplayHomeAsUpEnabled(isNavigationDrawerAvailable()); }
From source file:com.example.kaow.caltest.MainFrag.java
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.frag_main);/*from w ww . ja v a 2 s . co m*/ // Create the adapter that will return a fragment for each of the three primary sections // of the app. mAppSectionsPagerAdapter = new AppSectionsPagerAdapter(getSupportFragmentManager()); 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); // Set up the ViewPager, attaching the adapter and setting up a listener for when the // user swipes between sections. 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) { // 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 < mFoodTitles.length || i < mFoodIcon.length; i++) { actionBar.addTab(actionBar.newTab().setIcon(mFoodIcon[i]).setText(mFoodTitles[i]).setTabListener(this)); } }
From source file:de.mtrstudios.nflpickem.UI.Highscores.HighscoresActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_highscores); ButterKnife.inject(this); // Set up the action bar. final ActionBar actionBar = getActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); actionBar.setTitle(getString(R.string.highscores)); actionBar.setDisplayHomeAsUpEnabled(true); // Create the adapter that will return a fragment for each of the three // primary sections of the activity. mSectionsPagerAdapter = new SectionsPagerAdapter(getFragmentManager()); mSectionsPagerAdapter.setWeeks(appData.getSeasonInfo().getWeek()); // Set up the ViewPager with the sections adapter. mViewPager.setAdapter(mSectionsPagerAdapter); // 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. mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override// w w w .j a va2 s . com 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 < mSectionsPagerAdapter.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 callback (listener) for when // this tab is selected. actionBar .addTab(actionBar.newTab().setText(mSectionsPagerAdapter.getPageTitle(i)).setTabListener(this)); } }
From source file:de.d120.ophasekistenstapeln.NavigationDrawerFragment.java
/** * Users of this fragment must call this method to set up the navigation * drawer interactions.//from w w w .j ava2s .c om * * @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.xortech.multitag.TagAddMain.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.sender_tags); // REMOVE THE TITLE FROM THE ACTIONBAR ActionBar actionbar = getActionBar(); actionbar.setDisplayHomeAsUpEnabled(true); actionbar.setDisplayShowTitleEnabled(false); try {//from w w w . ja v a 2 s. co m tagList = (ListView) findViewById(R.id.tagList); tagList.setItemsCanFocus(false); addBtn = (Button) findViewById(R.id.add_btn); Set_Referash_Data(); } catch (Exception e) { Log.e("some error", "" + e); } addBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent addTag = new Intent(TagAddMain.this, TagAddUpdate.class); addTag.putExtra("called", "add"); addTag.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(addTag); finish(); } }); /** * LISTENER TO OPEN/CLOSE THE EXPANSION OF EACH CLICKED ITEM IN THE LISTVIEW */ tagList.setOnItemClickListener(new AdapterView.OnItemClickListener() { public void onItemClick(AdapterView<?> parent, final View view, int position, long id) { View toolbar = view.findViewById(R.id.expandable2); // CREATE AND EXPAND ANIMATION FOR THE ITEM ExpandAnimation expandAni = new ExpandAnimation(toolbar, 500); // START ANIMATION ON THE TOOLBAR toolbar.startAnimation(expandAni); } }); }
From source file:com.gmail.charleszq.picorner.ui.ImageDetailActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.image_detail_pager); // The ImageFetcher takes care of loading images into our ImageView // children asynchronously mImageFetcher = ImageLoader.getInstance(); // is offline enabled String isOfflineEnabledString = getIntent().getStringExtra(OFFLINE_COMMAND_KEY); if (isOfflineEnabledString != null) { mIsOfflineEnabled = Boolean.parseBoolean(isOfflineEnabledString); }/*from w w w . ja va 2s .co m*/ // Set up ViewPager and backing adapter mPhotosProvider = (IPhotosProvider) getIntent().getExtras().getSerializable(DP_KEY); mAdapter = new ImagePagerAdapter(mPhotosProvider, getSupportFragmentManager(), mPhotosProvider.getCurrentSize(), mIsOfflineEnabled); mPager = (ViewPager) findViewById(R.id.pager); mPager.setAdapter(mAdapter); mPager.setPageMargin((int) getResources().getDimension(R.dimen.image_detail_pager_margin)); mPager.setOffscreenPageLimit(2); // Set up activity to go full screen getWindow().addFlags(LayoutParams.FLAG_FULLSCREEN); final ActionBar actionBar = getActionBar(); // Hide title text and set home as up actionBar.setDisplayHomeAsUpEnabled(true); // actionBar.setDisplayShowTitleEnabled(false); // Hide and show the ActionBar as the visibility changes mPager.setOnSystemUiVisibilityChangeListener(new View.OnSystemUiVisibilityChangeListener() { @Override public void onSystemUiVisibilityChange(int vis) { boolean shown = true; if ((vis & View.SYSTEM_UI_FLAG_LOW_PROFILE) != 0) { actionBar.hide(); shown = false; } else { actionBar.show(); } if (mActionBarListeners != null) { for (IActionBarVisibleListener lis : mActionBarListeners) { lis.onActionBarShown(shown); } } } }); // Start low profile mode and hide ActionBar boolean showActionBar = getIntent().getBooleanExtra(SHOW_ACTION_BAR_KEY, true); if (!showActionBar) { mPager.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE); actionBar.hide(); } // Set the current item based on the extra passed in to this activity final int extraCurrentItem = getIntent().getIntExtra(LARGE_IMAGE_POSITION, -1); if (extraCurrentItem != -1) { mPager.setCurrentItem(extraCurrentItem); } boolean startSlide = getIntent().getBooleanExtra(SLIDE_SHOW_KEY, false); if (startSlide) { startSlideShow(1); } }