List of usage examples for android.app ActionBar setDisplayHomeAsUpEnabled
public abstract void setDisplayHomeAsUpEnabled(boolean showHomeAsUp);
From source file:com.lithiumli.fiction.NowPlayingActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.now_playing); initializeDrawer(false);/*from ww w . ja va2s .c om*/ mCoverPager = (AlbumSwiper) findViewById(R.id.cover_pager); mCoverPager.setListener(this); mSongName = (TextView) findViewById(R.id.np_song_name); mSongAlbum = (TextView) findViewById(R.id.np_song_album); mSongArtist = (TextView) findViewById(R.id.np_song_artist); mSongArtist.setSelected(true); ActionBar ab = getActionBar(); ab.setDisplayHomeAsUpEnabled(true); ab.setTitle("Now Playing"); mCache = ArtistImageCache.getInstance(this); setQueueMargin(); HandlerThread thread = new HandlerThread("thread"); thread.start(); mLooper = thread.getLooper(); mHandler = new Handler(mLooper); mFadeOut = new FadeOut(); mHandler.postDelayed(mFadeOut, 2000); }
From source file:net.callmeike.android.mojowire.ui.PodcastFragment.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 layout The DrawerLayout containing this fragment's UI. *///from www.j av a 2 s . c o m public void setUp(int fragmentId, DrawerLayout layout) { drawerLayout = layout; drawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START); fragmentContainerView = getActivity().findViewById(fragmentId); 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. drawerToggle = new PodcastActionBarDrawerToggle(this, drawerLayout, R.drawable.ic_drawer, R.string.navigation_drawer_open, R.string.navigation_drawer_close); // If the user hasn't 'learned' about the drawer, open it to introduce them to the drawer, // per the navigation drawer design guidelines. if (!drawerHasBeenSeen && !fromSavedInstanceState) { this.drawerLayout.openDrawer(fragmentContainerView); } // Defer code dependent on restoration of previous instance state. this.drawerLayout.post(new Runnable() { @Override public void run() { drawerToggle.syncState(); } }); this.drawerLayout.setDrawerListener(drawerToggle); }
From source file:org.ounl.noisenotifier.chart.PieChartActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.piechart);/*from w ww .j a v a 2 s. c om*/ db = new DatabaseHandler(getApplicationContext()); noiseUtils = new NoiseUtils(); Bundle extras = getIntent().getExtras(); if (extras != null) { mTag = extras.getString("TAG"); } 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 MinStepPJ ms = db.getMinStepNoiseSamples(mTag, Constants.NOISE_LEVELS); // Log.d(CLASSNAME, " Fruit " + NAME_LIST[i] + " / Count " + VALUES[i]); List<NoiseSaladPJ> las = db.getSalat(mTag, ms.getMinDecibels(), ms.getStepDecibels()); NAME_LIST = new String[las.size()]; VALUES = new double[las.size()]; int iNumRecords = 0; for (int i = 0; i < las.size(); i++) { NAME_LIST[i] = las.get(i).getIngredient(); VALUES[i] = las.get(i).getCount(); mSeries.add(NAME_LIST[i], VALUES[i]); SimpleSeriesRenderer ssr = new SimpleSeriesRenderer(); FeedbackColor fbc = noiseUtils.getFeedbackColor(i + 1, Constants.NOISE_LEVELS, 1); ssr.setColor(Color.parseColor(fbc.getHexColor())); //ssr.setColor(COLORS[(mSeries.getItemCount() - 1) % COLORS.length]); renderer.addSeriesRenderer(ssr); Log.d(CLASSNAME, i + " Fruit " + NAME_LIST[i] + " / Count " + 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:org.jorge.lolin1.ui.frags.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. *//* w w w . j av a2 s .c om*/ public void setUp(int fragmentId, FixedDrawerLayout 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.setHomeButtonEnabled(Boolean.TRUE); actionBar.setDisplayHomeAsUpEnabled(Boolean.TRUE); // ActionBarDrawerToggle ties together the the proper interactions // between the navigation drawer and the action bar app icon. mDrawerToggle = new FixedActionBarDrawerToggle(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; } restoreActionBar(); getActivity().invalidateOptionsMenu(); } @Override public void onDrawerOpened(View drawerView) { super.onDrawerOpened(drawerView); showGlobalContextActionBar(); } }; // 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:org.yuzhiqiang.itsmine.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 ww w.j a v a2 s.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:com.actionbarsherlock.sample.hcgallery.CameraFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); // Add an up arrow to the "home" button, indicating that the button will go "up" // one activity in the app's Activity heirarchy. // Calls to getActionBar() aren't guaranteed to return the ActionBar when called // from within the Fragment's onCreate method, because the Window's decor hasn't been // initialized yet. Either call for the ActionBar reference in Activity.onCreate() // (after the setContentView(...) call), or in the Fragment's onActivityCreated method. Activity activity = this.getActivity(); ActionBar actionBar = activity.getActionBar(); actionBar.setDisplayHomeAsUpEnabled(true); }
From source file:com.android.dialer.calllog.CallLogActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.call_log_activity); final ActionBar actionBar = getActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); actionBar.setDisplayShowHomeEnabled(true); actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setDisplayShowTitleEnabled(true); final Tab allTab = actionBar.newTab(); final String allTitle = getString(R.string.call_log_all_title); allTab.setContentDescription(allTitle); allTab.setText(allTitle);/*from w w w .j a v a 2 s . c om*/ allTab.setTabListener(mTabListener); actionBar.addTab(allTab); final Tab missedTab = actionBar.newTab(); final String missedTitle = getString(R.string.call_log_missed_title); missedTab.setContentDescription(missedTitle); missedTab.setText(missedTitle); missedTab.setTabListener(mTabListener); actionBar.addTab(missedTab); mViewPager = (ViewPager) findViewById(R.id.call_log_pager); mViewPagerAdapter = new ViewPagerAdapter(getFragmentManager()); mViewPager.setAdapter(mViewPagerAdapter); mViewPager.setOnPageChangeListener(mOnPageChangeListener); mViewPager.setOffscreenPageLimit(1); }
From source file:org.jorge.lolin1.ui.activities.ChatRoomActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ActionBar actionBar = getActionBar(); friendName = null;// w w w . ja va 2 s . c o m if (actionBar != null) { actionBar.setDisplayHomeAsUpEnabled(Boolean.TRUE); actionBar.setTitle(friendName = getIntent().getStringExtra(ChatOverviewActivity.KEY_FRIEND_NAME)); try { actionBar .setLogo( Drawable.createFromPath( ProfileCacheableBitmapLoader .getPathByID(getApplicationContext(), FriendManager.getInstance().findFriendByName(friendName) .getStatus().getProfileIconId()) .getAbsolutePath())); } catch (NullPointerException ex) { startActivity(new Intent(getApplicationContext(), ChatOverviewActivity.class));//Clicking notification with app closed finish(); return; } actionBar.setDisplayUseLogoEnabled(Boolean.TRUE); } ChatNotificationManager.dismissNotifications(getApplicationContext(), friendName); setContentView(R.layout.activity_chat_room); final EditText messageContentsTextField = (EditText) findViewById(android.R.id.inputArea); messageContentsTextField.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId != EditorInfo.IME_ACTION_DONE) return Boolean.FALSE; String contents = messageContentsTextField.getText().toString(); if (TextUtils.isEmpty(contents)) return Boolean.TRUE; adapter.add(new ChatMessageWrapper(contents, System.currentTimeMillis())); sendMessage(contents, friendName); messageContentsTextField.setText(""); messageContentsTextField.requestFocus(); return Boolean.TRUE; } private void sendMessage(String contents, String friendName) { new AsyncTask<String, Void, Void>() { @Override protected Void doInBackground(String... params) { Friend target; ChatMessageWrapper messageWrapper = new ChatMessageWrapper(params[0], System.currentTimeMillis()); logString("debug", "Sending message " + params[0] + " to " + params[1]); ChatBundleManager.addMessageToFriendChat(messageWrapper, target = FriendManager.getInstance().findFriendByName(params[1])); scrollListViewToBottom(); target.sendMessage(params[0]); return null; } }.executeOnExecutor(Executors.newSingleThreadExecutor(), contents, friendName); } }); conversationListView = (ListView) findViewById(android.R.id.list); conversationListView.setChoiceMode(AbsListView.CHOICE_MODE_NONE); logString("debug", "Calling adapter constructor"); adapter = new ChatRoomAdapter(getApplicationContext(), FriendManager.getInstance().findFriendByName(friendName)); if (!TextUtils.isEmpty(friendName)) conversationListView.setAdapter(adapter); scrollListViewToBottom(); registerLocalBroadcastReceiver(); scrollListViewToBottom(); }
From source file:com.android.talkback.tutorial.TutorialLessonFragment.java
@Override public void onResume() { super.onResume(); Activity activity = getActivity();//from ww w . ja v a 2s. c o m if (activity != null) { ActionBar actionBar = activity.getActionBar(); actionBar.setDisplayHomeAsUpEnabled(false); actionBar.setDisplayShowHomeEnabled(false); actionBar.setDisplayShowCustomEnabled(true); actionBar.setDisplayShowTitleEnabled(false); actionBar.setCustomView(R.layout.tutorial_action_bar); actionBar.getCustomView().findViewById(R.id.up).setOnClickListener(this); TextView title = (TextView) actionBar.getCustomView().findViewById(R.id.action_bar_title); title.setText(getTitle()); LocalBroadcastManager.getInstance(activity).registerReceiver(mActionMonitor, GestureActionMonitor.FILTER); } TalkBackService service = TalkBackService.getInstance(); if (service != null) { service.addEventListener(mExercise); } }
From source file:com.hellosky.recyclingimageloader.ImageDetailActivity.java
@TargetApi(11) @Override/*from w w w . ja v a2 s .c om*/ public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.image_detail_pager); // Fetch screen height and width, to use as our max size when loading images as this // activity runs full screen final DisplayMetrics displayMetrics = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(displayMetrics); final int height = displayMetrics.heightPixels; final int width = displayMetrics.widthPixels; // For this sample we'll use half of the longest width to resize our images. As the // image scaling ensures the image is larger than this, we should be left with a // resolution that is appropriate for both portrait and landscape. For best image quality // we shouldn't divide by 2, but this will use more memory and require a larger memory // cache. final int longest = (height > width ? height : width) / 2; mImageLoader = new ImageLoader(this); mImageLoader.setImageSize(longest); // Set up ViewPager and backing adapter mAdapter = new ImagePagerAdapter(getSupportFragmentManager(), Images.imageUrls.length); 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); // Enable some additional newer visibility and ActionBar features to create a more // immersive photo viewing experience if (Utils.hasHoneycomb()) { final ActionBar actionBar = getActionBar(); // Hide title text and set home as up actionBar.setDisplayShowTitleEnabled(false); actionBar.setDisplayHomeAsUpEnabled(true); // Hide and show the ActionBar as the visibility changes mPager.setOnSystemUiVisibilityChangeListener(new View.OnSystemUiVisibilityChangeListener() { @Override public void onSystemUiVisibilityChange(int vis) { if ((vis & View.SYSTEM_UI_FLAG_LOW_PROFILE) != 0) { actionBar.hide(); } else { actionBar.show(); } } }); // Start low profile mode and hide ActionBar 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(EXTRA_IMAGE, -1); if (extraCurrentItem != -1) { mPager.setCurrentItem(extraCurrentItem); } }