List of usage examples for android.app ActionBar setDisplayOptions
public abstract void setDisplayOptions(@DisplayOptions int options, @DisplayOptions int mask);
From source file:name.gumartinm.weather.information.activity.MainTabsActivity.java
@Override protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); this.setContentView(R.layout.weather_main_tabs); this.mPager = (ViewPager) this.findViewById(R.id.pager); this.mPager.setAdapter(new TabsAdapter(this.getSupportFragmentManager())); this.mPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override// w w w.j a v a 2s .c om public void onPageSelected(final int position) { MainTabsActivity.this.getActionBar().setSelectedNavigationItem(position); } }); final ActionBar actionBar = this.getActionBar(); PreferenceManager.setDefaultValues(this, R.xml.weather_preferences, false); // Specify that tabs should be displayed in the action bar. actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_TITLE, ActionBar.DISPLAY_SHOW_TITLE); actionBar.setDisplayHomeAsUpEnabled(true); // Create a tab listener that is called when the user changes tabs. final ActionBar.TabListener tabListener = new ActionBar.TabListener() { @Override public void onTabSelected(final Tab tab, final FragmentTransaction ft) { MainTabsActivity.this.mPager.setCurrentItem(tab.getPosition()); } @Override public void onTabUnselected(final Tab tab, final FragmentTransaction ft) { } @Override public void onTabReselected(final Tab tab, final FragmentTransaction ft) { } }; actionBar.addTab(actionBar.newTab().setText(this.getString(R.string.text_tab_currently)) .setTabListener(tabListener)); actionBar.addTab(actionBar.newTab().setText(this.getString(R.string.text_tab_five_days_forecast)) .setTabListener(tabListener)); }
From source file:com.ternup.caddisfly.activity.SurveyActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); this.setTheme(((MainApp) getApplicationContext()).CurrentTheme); setContentView(R.layout.fragment_survey); // BEGIN_INCLUDE (inflate_set_custom_view) // Inflate a "Done/Cancel" custom action bar view. final LayoutInflater inflater = (LayoutInflater) getActionBar().getThemedContext() .getSystemService(LAYOUT_INFLATER_SERVICE); final View customActionBarView = inflater.inflate(R.layout.actionbar_custom_view_done_cancel, null, false); final Context context = this; customActionBarView.findViewById(R.id.actionbar_done).setOnClickListener(new View.OnClickListener() { @Override//from w w w .j a va 2 s.co m public void onClick(View v) { long locationId = saveData(); if (locationId == -1) { mViewPager.setCurrentItem(1, true); AlertUtils.showMessage(context, R.string.incomplete, R.string.incompleteMessage); } else { Intent intent = new Intent(); intent.putExtra(getString(R.string.currentLocationId), locationId); setResult(Activity.RESULT_OK, intent); //todo: change to finished method isCancelled = true; finish(); } } }); customActionBarView.findViewById(R.id.actionbar_cancel).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { cancelSurvey(); } }); // Show the custom action bar view and hide the normal Home icon and title. final ActionBar actionBar = getActionBar(); actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM, ActionBar.DISPLAY_SHOW_CUSTOM | ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_SHOW_TITLE); actionBar.setCustomView(customActionBarView, new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); // END_INCLUDE (inflate_set_custom_view) // Create the adapter that will return a fragment for each of the three // primary sections of the activity. mSectionsPagerAdapter = new SectionsPagerAdapter(getFragmentManager()); mViewPager = (ViewPager) findViewById(R.id.viewpager); mViewPager.setOffscreenPageLimit(6); mViewPager.setAdapter(mSectionsPagerAdapter); mViewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() { @Override public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { } @Override public void onPageSelected(int position) { switch (position) { case 1: //mFormFragment.showKeyboard(); break; case 4: mNotesFragment.showKeyboard(); break; default: (new Handler()).postDelayed(new Runnable() { public void run() { ((InputMethodManager) getSystemService(INPUT_METHOD_SERVICE)) .hideSoftInputFromWindow(mViewPager.getWindowToken(), 0); } }, 300); } } @Override public void onPageScrollStateChanged(int state) { } }); // END_INCLUDE (setup_viewpager) // BEGIN_INCLUDE (setup_slidingTabLayout) // Give the SlidingTabLayout the ViewPager, this must be done AFTER the ViewPager has had // it's PagerAdapter set. /* A custom {@link android.support.v4.view.ViewPager} title strip which looks much like Tabs present in Android v4.0 and above, but is designed to give continuous feedback to the user when scrolling. */ SlidingTabLayout slidingTabLayout = (SlidingTabLayout) findViewById(R.id.sliding_tabs); slidingTabLayout.setViewPager(mViewPager); }
From source file:com.commonsware.android.feedfrags.FeedsNavActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main_nav);//from w ww . j av a 2s.c o m ActionBar bar = getActionBar(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { adapter = new ArrayAdapter<Feed>(bar.getThemedContext(), R.layout.row, Feed.getFeeds()); } else { adapter = new ArrayAdapter<Feed>(this, R.layout.row, Feed.getFeeds()); } bar.setListNavigationCallbacks(adapter, new NavListener()); bar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST); bar.setDisplayOptions(ActionBar.DISPLAY_SHOW_TITLE, ActionBar.DISPLAY_SHOW_TITLE); bar.setDisplayHomeAsUpEnabled(true); }
From source file:io.oceanos.shaderbox.ShaderEditorActivity.java
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); final LayoutInflater inflater = getLayoutInflater(); final View customActionBarView = inflater.inflate(R.layout.actionbar_view_save, null); final View shaderActionView = customActionBarView.findViewById(R.id.actionbar_view); final View shaderActionSave = customActionBarView.findViewById(R.id.actionbar_save); shaderActionView.setOnClickListener(new View.OnClickListener() { @Override// www. ja va2 s . c om public void onClick(View v) { if (result.isSuccess()) onView(shader); else { Toast errorMsg = Toast.makeText(getBaseContext(), result.getError(), Toast.LENGTH_LONG); errorMsg.getView().setBackgroundColor(getResources().getColor(R.color.editor_color_error)); errorMsg.show(); } } }); shaderActionSave.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { onSave(shader); } }); fps = (TextView) customActionBarView.findViewById(R.id.text_fps); viewError = (TextView) shaderActionView.findViewById(R.id.viewError); final ActionBar actionBar = getActionBar(); actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM, ActionBar.DISPLAY_SHOW_CUSTOM | ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_SHOW_TITLE); actionBar.setCustomView(customActionBarView, new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); setContentView(R.layout.activity_editor); Intent intent = getIntent(); String action = intent.getAction(); String type = intent.getType(); ShaderDatabase database = new ShaderDatabase(getBaseContext()); if (Intent.ACTION_SEND.equals(action) && type != null) { if ("text/plain".equals(type)) { String sharedText = intent.getStringExtra(Intent.EXTRA_TEXT); long id = database.newShader(); Cursor cursor = database.findById(id); if (cursor.moveToFirst()) shader = Shader.getValues(cursor); cursor.close(); if (sharedText != null) shader.setText(sharedText); else shader.setText(""); } } else { long id = intent.getLongExtra("ID", 0); Cursor cursor = database.findById(id); if (cursor.moveToFirst()) shader = Shader.getValues(cursor); cursor.close(); } database.close(); setSymbolListener(R.id.action_tab, '\t'); setSymbolListener(R.id.action_rpo, '('); setSymbolListener(R.id.action_rpc, ')'); setSymbolListener(R.id.action_cpo, '{'); setSymbolListener(R.id.action_cpc, '}'); setSymbolListener(R.id.action_dotcoma, ';'); setSymbolListener(R.id.action_coma, ','); setSymbolListener(R.id.action_dot, '.'); setSymbolListener(R.id.action_plus, '+'); setSymbolListener(R.id.action_minus, '-'); setSymbolListener(R.id.action_times, '*'); setSymbolListener(R.id.action_div, '/'); setSymbolListener(R.id.action_equal, '='); setSymbolListener(R.id.action_spo, '['); setSymbolListener(R.id.action_spc, ']'); setSymbolListener(R.id.action_and, '&'); setSymbolListener(R.id.action_or, '|'); setSymbolListener(R.id.action_greater, '>'); setSymbolListener(R.id.action_lesser, '<'); setSymbolListener(R.id.action_cardinal, '#'); final Handler uiHandler = new Handler(this); renderer = new ShaderRenderer(shader, uiHandler); shaderView = (ShaderGLView) findViewById(R.id.shader_view); shaderView.setRenderer(renderer); shaderView.setVRModeEnabled(false); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); int textSize = Integer.parseInt(prefs.getString("pref_editor_text_size", "14")); int opacity = Integer.parseInt(prefs.getString("pref_editor_opacity", "127")); editor = (ShaderEditor) findViewById(R.id.editor); editor.setTextSize(textSize); editor.setBackgroundColor(opacity << 24); editor.setHorizontallyScrolling(true); editor.setHorizontalScrollBarEnabled(true); editor.setText(shader.getText()); ScrollView scroll = (ScrollView) findViewById(R.id.scroll); editor.setScrollView(scroll); compileRT = prefs.getBoolean("pref_compile_rt", true); }
From source file:com.android.ex.photo.PhotoViewActivity.java
/** * Adjusts the activity title and subtitle to reflect the photo name and count. *//*from ww w. j a va 2 s .c om*/ protected void updateActionBar(PhotoViewFragment fragment) { final int position = mViewPager.getCurrentItem() + 1; final String title; final String subtitle; final boolean hasAlbumCount = mAlbumCount >= 0; final Cursor cursor = getCursorAtProperPosition(); if (cursor != null) { final int photoNameIndex = cursor.getColumnIndex(PhotoContract.PhotoViewColumns.NAME); title = cursor.getString(photoNameIndex); } else { title = null; } if (mIsEmpty || !hasAlbumCount || position <= 0) { subtitle = null; } else { subtitle = getResources().getString(R.string.photo_view_count, position, mAlbumCount); } final ActionBar actionBar = getActionBar(); actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_TITLE, ActionBar.DISPLAY_SHOW_TITLE); actionBar.setTitle(title); actionBar.setSubtitle(subtitle); }
From source file:cn.studyjams.s2.sj0132.bowenyan.mygirlfriend.nononsenseapps.notepad.ui.widget.ListWidgetConfig.java
void setupActionBar() { final WidgetPrefs widgetPrefs = new WidgetPrefs(this, appWidgetId); LayoutInflater inflater = (LayoutInflater) getActionBar().getThemedContext() .getSystemService(LAYOUT_INFLATER_SERVICE); final View customActionBarView = inflater.inflate(R.layout.actionbar_custom_view_done, null); customActionBarView.findViewById(R.id.actionbar_done).setOnClickListener(new View.OnClickListener() { @Override//from ww w. ja v a2 s . c o m public void onClick(View v) { // "Done" // // Set success widgetPrefs.setPresent(); Intent resultValue = new Intent(); resultValue.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId); setResult(RESULT_OK, resultValue); // Build/Update widget AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(getApplicationContext()); // Log.d(TAG, "finishing WidgetId " + appWidgetId); appWidgetManager.updateAppWidget(appWidgetId, ListWidgetProvider .buildRemoteViews(getApplicationContext(), appWidgetManager, appWidgetId, widgetPrefs)); // Update list items appWidgetManager.notifyAppWidgetViewDataChanged(appWidgetId, R.id.notesList); // Destroy activity finish(); } }); // Show the custom action bar view and hide the normal Home icon and // title. final ActionBar actionBar = getActionBar(); actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM, ActionBar.DISPLAY_SHOW_CUSTOM | ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_SHOW_TITLE); actionBar.setCustomView(customActionBarView); }
From source file:com.roque.rueda.cashflows.fragments.AddMovementFragment.java
/** * Show a custom action bar in the activity. * @param inflater Inflater used to create the widgets. *///ww w .j av a2 s . c o m private void createActionBar(LayoutInflater inflater) { final View customActionBarView = inflater.inflate(R.layout.actionbar_done_cancel, null); customActionBarView.findViewById(R.id.actionbar_done).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // Done. //Toast.makeText(getActivity(), R.string.accept, Toast.LENGTH_SHORT).show(); Movement cashMovement = new Movement(); cashMovement.setAmount(getInputAmount()); cashMovement.setDate(new Date(getInputDate())); cashMovement.setDescription(getInputNotes()); if (mIsNegative) { cashMovement.setSing("-"); } else { cashMovement.setSing("+"); } cashMovement.setIdAccount(mAccountsSpinner.getSelectedItemId()); mCashState.saveCashMovement(cashMovement); Toast.makeText(getActivity(), R.string.movement_save_message, Toast.LENGTH_SHORT).show(); Intent intent = new Intent(); // Indicate to parent activity that the information was store. intent.putExtra(MainActivity.ADD_MOVEMENT_RESULT, true); getActivity().setResult(MainActivity.REQUEST_CODE, intent); getActivity().finish(); } }); customActionBarView.findViewById(R.id.actionbar_cancel).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // Cancel getActivity().finish(); } }); final ActionBar actionBar = getActivity().getActionBar(); if (actionBar != null) { actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM, ActionBar.DISPLAY_SHOW_CUSTOM | ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_SHOW_TITLE); actionBar.setCustomView(customActionBarView, new ActionBar.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); } }
From source file:com.android.ex.photo.PhotoViewActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); final ActivityManager mgr = (ActivityManager) getApplicationContext() .getSystemService(Activity.ACTIVITY_SERVICE); sMemoryClass = mgr.getMemoryClass(); Intent mIntent = getIntent();//from w w w .j ava 2 s . co m int currentItem = -1; if (savedInstanceState != null) { currentItem = savedInstanceState.getInt(STATE_ITEM_KEY, -1); mFullScreen = savedInstanceState.getBoolean(STATE_FULLSCREEN_KEY, false); } // uri of the photos to view; optional if (mIntent.hasExtra(Intents.EXTRA_PHOTOS_URI)) { mPhotosUri = mIntent.getStringExtra(Intents.EXTRA_PHOTOS_URI); } // projection for the query; optional // I.f not set, the default projection is used. // This projection must include the columns from the default projection. if (mIntent.hasExtra(Intents.EXTRA_PROJECTION)) { mProjection = mIntent.getStringArrayExtra(Intents.EXTRA_PROJECTION); } else { mProjection = null; } // Set the current item from the intent if wasn't in the saved instance if (mIntent.hasExtra(Intents.EXTRA_PHOTO_INDEX) && currentItem < 0) { currentItem = mIntent.getIntExtra(Intents.EXTRA_PHOTO_INDEX, -1); } mPhotoIndex = currentItem; setContentView(R.layout.photo_activity_view); // Create the adapter and add the view pager mAdapter = new PhotoPagerAdapter(this, getFragmentManager(), null); mViewPager = (PhotoViewPager) findViewById(R.id.photo_view_pager); mViewPager.setAdapter(mAdapter); mViewPager.setOnPageChangeListener(this); mViewPager.setOnInterceptTouchListener(this); // Kick off the loader getLoaderManager().initLoader(LOADER_PHOTO_LIST, null, this); final ActionBar actionBar = getActionBar(); actionBar.setDisplayHomeAsUpEnabled(true); mActionBarHideDelayTime = getResources().getInteger(R.integer.action_bar_delay_time_in_millis); actionBar.addOnMenuVisibilityListener(this); actionBar.setDisplayOptions(0, ActionBar.DISPLAY_SHOW_TITLE); }
From source file:com.android.contacts.activities.ContactDetailActivity.java
/** @} */ @Override//from w w w . j ava 2 s . c om protected void onCreate(Bundle savedState) { super.onCreate(savedState); LogUtils.i(TAG, "[onCreate][launch]start"); ///M: Bug Fix for ALPS01022809,JE happens when click the favourite video to choose contact in tablet registerPHBReceiver(); mIsActivitFinished = false; /** M: Bug Fix for ALPS00393950 @{ */ boolean isUsingTwoPanes = PhoneCapabilityTester.isUsingTwoPanes(this); if (!isUsingTwoPanes) { SetIndicatorUtils.getInstance().registerReceiver(this); } /** @} */ if (PhoneCapabilityTester.isUsingTwoPanes(this)) { // This activity must not be shown. We have to select the contact in the // PeopleActivity instead ==> Create a forward intent and finish final Intent originalIntent = getIntent(); Intent intent = new Intent(); intent.setAction(originalIntent.getAction()); intent.setDataAndType(originalIntent.getData(), originalIntent.getType()); // If we are launched from the outside, we should create a new task, because the user // can freely navigate the app (this is different from phones, where only the UP button // kicks the user into the full app) if (shouldUpRecreateTask(intent)) { intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); } else { intent.setFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS | Intent.FLAG_ACTIVITY_FORWARD_RESULT | Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP); } intent.setClass(this, PeopleActivity.class); startActivity(intent); LogUtils.i(TAG, "onCreate(),Using Two Panes...finish Actiivity.."); finish(); return; } setContentView(R.layout.contact_detail_activity); mContactDetailLayoutController = new ContactDetailLayoutController(this, savedState, getFragmentManager(), null, findViewById(R.id.contact_detail_container), mContactDetailFragmentListener); // We want the UP affordance but no app icon. // Setting HOME_AS_UP, SHOW_TITLE and clearing SHOW_HOME does the trick. ActionBar actionBar = getActionBar(); if (actionBar != null) { ///@Modify for add Customer view{ actionBar.setDisplayOptions( ActionBar.DISPLAY_HOME_AS_UP | ActionBar.DISPLAY_SHOW_TITLE | ActionBar.DISPLAY_SHOW_CUSTOM, ActionBar.DISPLAY_HOME_AS_UP | ActionBar.DISPLAY_SHOW_TITLE | ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_SHOW_CUSTOM); ///@} actionBar.setTitle(""); } Log.i(TAG, getIntent().getData().toString()); /** M: New Feature xxx @{ */ //M:fix CR:ALPS00958663,disconnect to smartbook when contact screen happen JE if (getIntent() != null && getIntent().getData() != null) { mSimOrPhoneUri = getIntent().getData(); Log.i(TAG, "mSimOrPhoneUri = " + mSimOrPhoneUri); } else { Log.e(TAG, "Get intent data error getIntent() = " + getIntent()); } /// M: @ CT contacts detail history set listener{ ExtensionManager.getInstance().getContactDetailEnhancementExtension().configActionBarExt(getActionBar(), ContactPluginDefault.COMMD_FOR_OP09); /// @} LogUtils.i(TAG, "[onCreate][launch]end"); }
From source file:com.mediatek.galleryfeature.stereo.segment.background.StereoBackgroundActivity.java
private void setActionBarDisplayOptions(ActionBar actionBar, boolean displayHomeAsUp, boolean showTitle) { if (actionBar == null) { return;// w w w . j av a 2s . co m } int options = 0; if (displayHomeAsUp) { options |= ActionBar.DISPLAY_HOME_AS_UP; } if (showTitle) { options |= ActionBar.DISPLAY_SHOW_TITLE; } actionBar.setDisplayOptions(options, ActionBar.DISPLAY_HOME_AS_UP | ActionBar.DISPLAY_SHOW_TITLE); actionBar.setHomeButtonEnabled(displayHomeAsUp); actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM); actionBar.setTitle(R.string.m_save); }