List of usage examples for android.app ActionBar setTitle
public abstract void setTitle(@StringRes int resId);
From source file:io.coldstart.android.TrapListActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); BugSenseHandler.initAndStartSession(TrapListActivity.this, "b569cf15"); setContentView(R.layout.activity_trap_list); securityID = API.md5(Settings.Secure.getString(getContentResolver(), Settings.Secure.ANDROID_ID)); ActionBar ab = getActionBar(); ab.setTitle("ColdStart.io"); ab.setSubtitle("Instant SNMP Trap Alerting"); //Start the service just in case //Gets round http://developer.android.com/reference/android/content/Intent.html#FLAG_INCLUDE_STOPPED_PACKAGES startService(new Intent(this, ColdStartService.class)); //GCM stuff/*from w ww .ja v a 2 s.co m*/ GCMRegistrar.checkDevice(this); GCMRegistrar.checkManifest(this); regId = GCMRegistrar.getRegistrationId(this); if (regId.equals("")) { Log.v("GCM", "Registering"); GCMRegistrar.register(this, API.SENDER_ID); } else { Log.v("GCM", "Already registered"); } Log.e("GCMID", GCMRegistrar.getRegistrationId(this)); settings = PreferenceManager.getDefaultSharedPreferences(this); if (settings.getBoolean("firstRun", true)) { showChooseDialog(); } else { subscribeToMessages(); } if (findViewById(R.id.trap_detail_container) != null) { // The detail container view will be present only in the // large-screen layouts (res/values-large and // res/values-sw600dp). If this view is present, then the // activity should be in two-pane mode. mTwoPane = true; // In two-pane mode, list items should be given the // 'activated' state when touched. ((TrapListFragment) getSupportFragmentManager().findFragmentById(R.id.trap_list)) .setActivateOnItemClick(true); if (savedInstanceState == null) { WelcomeFragment fragment = new WelcomeFragment(); //fragment.setArguments(arguments); getSupportFragmentManager().beginTransaction().replace(R.id.trap_detail_container, fragment) .commit(); } } // TODO: If exposing deep links into your app, handle intents here. }
From source file:com.example.swipeuiforupclose.MainActivity.java
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.profile_main); // 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./*from ww w . j a v a 2 s . co m*/ actionBar.setHomeButtonEnabled(false); actionBar.setBackgroundDrawable(new ColorDrawable(0xFF46304e)); actionBar.setStackedBackgroundDrawable(new ColorDrawable(0xFF573d5d)); actionBar.setTitle("My Profile"); // Specify that we will be displaying tabs in the action bar. //actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); 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().setText(mAppSectionsPagerAdapter.getPageTitle(i)).setTabListener(this)); } }
From source file:com.deange.textfaker.ui.activity.MessageActivity.java
private void setupActionBar() { final ActionBar actionBar = getActionBar(); if (actionBar != null) { actionBar.setDisplayHomeAsUpEnabled(true); if (mConversation != null) { actionBar.setTitle(mConversation.getName()); actionBar.setSubtitle(mConversation.getNumber()); }/*from w w w .j a va 2s . c o m*/ } }
From source file:com.example.gangzhang.myapplication.VideoPlayerActivity.java
public void restoreActionBar() { ActionBar actionBar = getActionBar(); actionBar.setDisplayShowTitleEnabled(true); actionBar.setTitle(getTitle()); actionBar.setIcon(null);//from w ww. ja v a 2 s. c om actionBar.setDisplayUseLogoEnabled(false); }
From source file:name.gumartinm.weather.information.activity.MapActivity.java
@Override public void onResume() { super.onResume(); final ActionBar actionBar = this.getActionBar(); actionBar.setTitle(this.getString(R.string.weather_map_mark_location)); WeatherLocation weatherLocation;//from w w w.j av a 2 s .c o m if (this.mRestoreUI != null) { // Restore UI state weatherLocation = this.mRestoreUI; // just once this.mRestoreUI = null; } else if (this.mMarker != null) { final TextView city = (TextView) this.findViewById(R.id.weather_map_city); final TextView country = (TextView) this.findViewById(R.id.weather_map_country); final String cityString = city.getText().toString(); final String countryString = country.getText().toString(); final LatLng point = this.mMarker.getPosition(); double latitude = point.latitude; double longitude = point.longitude; weatherLocation = new WeatherLocation().setCity(cityString).setCountry(countryString) .setLatitude(latitude).setLongitude(longitude); } else { final DatabaseQueries query = new DatabaseQueries(this.getApplicationContext()); weatherLocation = query.queryDataBase(); } if (weatherLocation != null) { this.updateUI(weatherLocation); } }
From source file:com.robandjen.comicsapp.FullscreenActivity.java
void showCurrentComic(String url) { if (url == null || url.isEmpty()) { url = mComicList.get(mCurComic).getURL(); }/* www . j a va2 s.c o m*/ final WebView contentView = (WebView) findViewById(R.id.fullscreen_content); contentView.stopLoading(); //Load about:blank to clear any extra data and have a well defined URL in history contentView.loadUrl("about:blank"); contentView.loadUrl(url); contentView.clearHistory(); ActionBar actionBar = getActionBar(); if (actionBar != null) { actionBar.setTitle(mComicList.get(mCurComic).getName()); } updateShare(url); ExpandableListView elv = (ExpandableListView) findViewById(R.id.comic_drawer); long packedPos = mAdapter.comicsPosToPackedPos(mCurComic); //Selection doesn't work if expandGroup isn't called or group already expanded. ????? elv.expandGroup(ExpandableListView.getPackedPositionGroup(packedPos)); elv.setSelectedChild(ExpandableListView.getPackedPositionGroup(packedPos), ExpandableListView.getPackedPositionChild(packedPos), true); elv.setItemChecked(elv.getFlatListPosition(packedPos), true); }
From source file:com.simplelife.seeds.android.utils.gridview.gridviewui.ImageGridFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final View v = inflater.inflate(R.layout.activity_seeds_gridview_gridfragment, container, false); final GridView mGridView = (GridView) v.findViewById(R.id.gridView); mPullToRefreshView = (SeedsPullToRefreshView) v.findViewById(R.id.main_pull_refresh_view_grid); mGridView.setAdapter(mAdapter);//from ww w. j a v a 2s . c om mGridView.setOnItemClickListener(this); mPullToRefreshView.setOnHeaderRefreshListener(this); mGridView.setOnScrollListener(new AbsListView.OnScrollListener() { @Override public void onScrollStateChanged(AbsListView absListView, int scrollState) { // Pause fetcher to ensure smoother scrolling when flinging if (scrollState == AbsListView.OnScrollListener.SCROLL_STATE_FLING) { mImageFetcher.setPauseWork(true); } else { mImageFetcher.setPauseWork(false); } } @Override public void onScroll(AbsListView absListView, int firstVisibleItem, int visibleItemCount, int totalItemCount) { } }); // This listener is used to get the final width of the GridView and then calculate the // number of columns and the width of each column. The width of each column is variable // as the GridView has stretchMode=columnWidth. The column width is used to set the height // of each view so we get nice square thumbnails. mGridView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { @Override public void onGlobalLayout() { if (mAdapter.getNumColumns() == 0) { final int numColumns = (int) Math .floor(mGridView.getWidth() / (mImageThumbSize + mImageThumbSpacing)); if (numColumns > 0) { final int columnWidth = (mGridView.getWidth() / numColumns) - mImageThumbSpacing; mAdapter.setNumColumns(numColumns); mAdapter.setItemHeight(columnWidth); if (BuildConfig.DEBUG) { Log.d(TAG, "onCreateView - numColumns set to " + numColumns); } } } } }); // Set a title for this page ActionBar tActionBar = getActivity().getActionBar(); tActionBar.setTitle(R.string.seeds_details_top); // Show the details info of the seed // Prepare the seeds text info String tSeedName = Images.getSeedsEntity().getSeedName(); String tSeedSize = Images.getSeedsEntity().getSeedSize(); String tSeedFormat = Images.getSeedsEntity().getSeedFormat(); String tSeedMosaic = (Images.getSeedsEntity().getSeedMosaic()) ? getString(R.string.seeds_listperday_withmosaic) : getString(R.string.seeds_listperday_withoutmosaic); TextView tTextViewName = (TextView) v.findViewById(R.id.seed_grid_info_name); TextView tTextViewFormat = (TextView) v.findViewById(R.id.seed_grid_info_format); TextView tTextViewSize = (TextView) v.findViewById(R.id.seed_grid_info_size); TextView tTextViewMosaic = (TextView) v.findViewById(R.id.seed_grid_info_mosaic); if (null != tSeedName) tTextViewName.setText(getString(R.string.seedTitle) + ": " + tSeedName); if (null != tSeedFormat) tTextViewFormat.setText(getString(R.string.seedFormat) + ": " + tSeedFormat); if (null != tSeedSize) tTextViewSize.setText(getString(R.string.seedSize) + ": " + tSeedSize); if (null != tSeedMosaic) tTextViewMosaic.setText(getString(R.string.seeds_listperday_mosaic) + ": " + tSeedMosaic); return v; }
From source file:com.android.camera.settings.CameraSettingsActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); FatalErrorHandler fatalErrorHandler = new FatalErrorHandlerImpl(this); boolean hideAdvancedScreen = false; try {/*ww w . j av a2 s. c om*/ mOneCameraManager = OneCameraModule.provideOneCameraManager(); } catch (OneCameraException e) { // Log error and continue. Modules requiring OneCamera should check // and handle if null by showing error dialog or other treatment. fatalErrorHandler.onGenericCameraAccessFailure(); } // Check if manual exposure is available, so we can decide whether to // display Advanced screen. try { CameraId frontCameraId = mOneCameraManager.findFirstCameraFacing(Facing.FRONT); CameraId backCameraId = mOneCameraManager.findFirstCameraFacing(Facing.BACK); // The exposure compensation is supported when both of the following conditions meet // - we have the valid camera, and // - the valid camera supports the exposure compensation boolean isExposureCompensationSupportedByFrontCamera = (frontCameraId != null) && (mOneCameraManager .getOneCameraCharacteristics(frontCameraId).isExposureCompensationSupported()); boolean isExposureCompensationSupportedByBackCamera = (backCameraId != null) && (mOneCameraManager .getOneCameraCharacteristics(backCameraId).isExposureCompensationSupported()); // Hides the option if neither front and back camera support exposure compensation. if (!isExposureCompensationSupportedByFrontCamera && !isExposureCompensationSupportedByBackCamera) { hideAdvancedScreen = true; } } catch (OneCameraAccessException e) { fatalErrorHandler.onGenericCameraAccessFailure(); } ActionBar actionBar = getActionBar(); actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setTitle(R.string.mode_settings); String prefKey = getIntent().getStringExtra(PREF_SCREEN_EXTRA); CameraSettingsFragment dialog = new CameraSettingsFragment(); Bundle bundle = new Bundle(1); bundle.putString(PREF_SCREEN_EXTRA, prefKey); bundle.putBoolean(HIDE_ADVANCED_SCREEN, hideAdvancedScreen); dialog.setArguments(bundle); getFragmentManager().beginTransaction().replace(android.R.id.content, dialog).commit(); }
From source file:cs.man.ac.uk.tavernamobile.WorkflowDetail.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.workflow_detail); Activity_Starter_Code = 1;//from w w w . ja va 2 s .c o m imageCache = TavernaAndroid.getmMemoryCache(); mCache = TavernaAndroid.getmTextCache(); currentActivity = this; // for the access of current activity in // OnClickListener SlidingMenu slidingMenu = new SlidingMenu(this); slidingMenu.setMode(SlidingMenu.LEFT); slidingMenu.setTouchModeAbove(SlidingMenu.TOUCHMODE_MARGIN); slidingMenu.setShadowWidthRes(R.dimen.shadow_width); slidingMenu.setShadowDrawable(R.drawable.shadow); slidingMenu.setBehindOffsetRes(R.dimen.slidingmenu_offset); slidingMenu.setFadeDegree(0.35f); slidingMenu.attachToActivity(this, SlidingMenu.SLIDING_CONTENT); slidingMenu.setMenu(R.layout.sliding_menu); // UI components ActionBar actionBar = getActionBar(); actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setTitle("Workflow Details"); actionBar.setIcon(this.getResources().getDrawable(R.drawable.taverna_wheel_logo_medium)); // avatar = (ImageView) findViewById(R.id.avatarImage); title = (TextView) findViewById(R.id.workflowTitle); TextView version = (TextView) findViewById(R.id.workflowVersion); userName = (TextView) findViewById(R.id.uploaderName); final Button launch = (Button) findViewById(R.id.workflowlaunchButton); // try to get data passed and then load other data e.g. license etc. workflow = (Workflow) getIntent().getSerializableExtra("workflow_details"); // If no data passed in - activity restored etc. // get data from memory if the activity was in back stack if (workflow == null) { workflow = (Workflow) mCache.get("workflow"); license = (License) mCache.get("license"); uploader = (User) mCache.get("uploader"); } // if it is not in Cache else if (workflow == null) { // try to get data from savedInstanceState if the activity // was killed due to low memory etc. if (savedInstanceState != null) { // try to get data from saved instance state if (workflow == null) { workflow = (Workflow) savedInstanceState.getSerializable("workflow"); } if (license == null) { license = (License) savedInstanceState.getSerializable("license"); } if (uploader == null) { uploader = (User) savedInstanceState.getSerializable("uploader"); } } } else if (workflow == null) { // if data can't even be loaded from // saved instance state, inform user // to try start the activity again, // rather than crash the application MessageHelper.showMessageDialog(currentActivity, "Oops !", "No workflow data found," + "please try again.\n(The message will be dismissed in 4 seconds)", null); new Handler().postDelayed(new Runnable() { public void run() { currentActivity.finish(); } }, 4000); return; } /** "workflow" should never be null at this point **/ title.setText(workflow.getTitle()); version.setText("Version " + workflow.getVersion()); // any of the following is null we retrieve data from the server if (license == null || uploader == null || avatarBitmap == null) { BackgroundTaskHandler handler = new BackgroundTaskHandler(); handler.StartBackgroundTask(this, this, "Loading workflow data..."); } else { // load avatar image from cache avatarBitmap = imageCache.get(uploader.getAvatar().getResource()); } launch.setOnClickListener(new android.view.View.OnClickListener() { public void onClick(View v) { SystemStatesChecker sysChecker = new SystemStatesChecker(currentActivity); if (!(sysChecker.isNetworkConnected())) { return; } WorkflowBE workflowEntity = new WorkflowBE(); workflowEntity.setTitle(workflow.getTitle()); workflowEntity.setVersion(workflow.getVersion()); workflowEntity.setWorkflow_URI(workflow.getContent_uri()); workflowEntity.setUploaderName(workflow.getUploader().getValue()); workflowEntity.setAvatar(Bitmap.createScaledBitmap(avatarBitmap, 100, 100, true)); List<String> privilegesStrings = new ArrayList<String>(); List<Privilege> privileges = workflow.getPrivileges(); for (Privilege privilege : privileges) { privilegesStrings.add(privilege.getType()); } workflowEntity.setPrivileges(privilegesStrings); WorkflowLaunchHelper launchHelper = new WorkflowLaunchHelper(currentActivity, Activity_Starter_Code); launchHelper.launch(workflowEntity, 0); } }); // Set up fragments DetailsPreviewFragment previewFragment = new DetailsPreviewFragment(); DetailsDescriptionFragment descriptionFragment = new DetailsDescriptionFragment(); DetailsLicenseFragment licenseFragment = new DetailsLicenseFragment(); mSectionsPagerAdapter = new MyPagerAdapter(getSupportFragmentManager()); mSectionsPagerAdapter.addFragment(previewFragment); mSectionsPagerAdapter.addFragment(descriptionFragment); mSectionsPagerAdapter.addFragment(licenseFragment); mViewPager = (ViewPager) findViewById(R.id.workflowDetailsViewPager); mViewPager.setAdapter(mSectionsPagerAdapter); mViewPager.setOffscreenPageLimit(2); mViewPager.setCurrentItem(0); /*myExperimentLoginText = (TextView) findViewById(R.id.wfdMyExperimentLoginState); myExperimentLoginText.setOnClickListener(new android.view.View.OnClickListener() { @Override public void onClick(View v) { User user = TavernaAndroid.getMyEUserLoggedin(); if (user != null) { MessageHelper.showOptionsDialog(currentActivity, "Do you wish to log out ?", "Attention", new CallbackTask() { @Override public Object onTaskInProgress(Object... param) { // Clear user logged-in and cookie TavernaAndroid.setMyEUserLoggedin(null); TavernaAndroid.setMyExperimentSessionCookies(null); refreshLoginState(); return null; } @Override public Object onTaskComplete(Object... result) {return null;} }, null); }else{ Intent gotoMyexperimentLogin = new Intent( currentActivity, MyExperimentLogin.class); currentActivity.startActivity(gotoMyexperimentLogin); } } });*/ this.overridePendingTransition(R.anim.push_left_in, R.anim.push_left_out); }
From source file:nz.ac.otago.psyanlab.common.PaleActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_pale); // Get and initialise user delegate. if (getIntent().hasExtra(Args.USER_DELEGATE)) { mUserDelegate = getIntent().getParcelableExtra(Args.USER_DELEGATE); mUserDelegate.init(this); } else {//ww w . jav a 2 s.c o m throw new IllegalStateException("User delegate must be provided."); } // Initialise action bar. ActionBar actionBar = getActionBar(); String title = mUserDelegate.getUserName(); if (TextUtils.isEmpty(title)) { title = getString(R.string.app_name); actionBar.setDisplayHomeAsUpEnabled(false); } else { actionBar.setDisplayHomeAsUpEnabled(true); } actionBar.setTitle(title); // Initialise fragments. FragmentManager fm = getSupportFragmentManager(); // List fragment. mPaleListFragment = (PaleListFragment) fm.findFragmentById(R.id.pale_list_fragment); mPaleListFragment.setUserDelegate(mUserDelegate); mPaleListFragment.setActivateOnItemClick(true); // if (savedInstanceState == null) { // mPaleListFragment.setActivatedPosition(0); // } // Detail fragment. mPaleDetailFragment = (PaleDetailFragment) fm.findFragmentById(R.id.pale_detail_fragment); if (savedInstanceState != null) { updateExperimentDelegate( savedInstanceState.<UserExperimentDelegateI>getParcelable(Args.USER_EXPERIMENT_DELEGATE)); } // Initialise sliding container. mSlidingContainer = (SlidingPaneLayout) findViewById(R.id.sliding_container); mSlidingContainer .setParallaxDistance((int) getResources().getDimension(R.dimen.sliding_container_parallax)); new Handler().postDelayed(new Runnable() { @Override public void run() { if (mSlidingContainer.isSlideable()) { mSlidingContainer.setShadowResource(R.drawable.opal_list_background); mSlidingContainer.invalidate(); } else { mSlidingContainer.setShadowResource(R.drawable.opal_list_background_flat); mSlidingContainer.invalidate(); } } }, 100); }