Java Code Examples for android.support.v7.app.ActionBar#setDisplayOptions()
The following examples show how to use
android.support.v7.app.ActionBar#setDisplayOptions() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MainActivity.java From QueryHighlighter with Apache License 2.0 | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mAdapter = new CheesesAdapter(); final ListView listView = (ListView) findViewById(android.R.id.list); listView.setAdapter(mAdapter); final ActionBar actionBar = getSupportActionBar(); actionBar.setCustomView(R.layout.search_view); actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM); final EditText editText = (EditText) actionBar.getCustomView(); editText.addTextChangedListener(mTextWatcher); editText.requestFocus(); }
Example 2
Source File: MainActivity.java From android-weather with MIT License | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); if (getSupportActionBar() != null) { ActionBar actionBar = getSupportActionBar(); actionBar.setDisplayShowHomeEnabled(false); View mActionBarView = getLayoutInflater().inflate(R.layout.main_action_bar, null); actionBar.setCustomView(mActionBarView); actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM); } mLocationManager = (LocationManager) getSystemService(LOCATION_SERVICE); // mLocationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, MAX_TIME, // MAX_DISTANCE, mLocationListener); if (savedInstanceState == null) { getSupportFragmentManager().beginTransaction() .add(R.id.container, new TenDayForecastFragment()) .commit(); } }
Example 3
Source File: BaseActivity.java From SpecialAlarmClock with Apache License 2.0 | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ActionBar actionBar = getSupportActionBar(); actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM); actionBar.setCustomView(R.layout.middle_title_actionbar); try { ViewConfiguration config = ViewConfiguration.get(this); Field menuKeyField = ViewConfiguration.class.getDeclaredField("sHasPermanentMenuKey"); if (menuKeyField != null) { menuKeyField.setAccessible(true); menuKeyField.setBoolean(config, false); } } catch (Exception ex) { // Ignore } }
Example 4
Source File: NetMediaActivty.java From KSYMediaPlayer_Android with Apache License 2.0 | 6 votes |
public void setActionBarLayout(int layoutId, Context mContext) { ActionBar actionBar = getSupportActionBar(); if (null != actionBar) { actionBar.setDisplayShowHomeEnabled(false); actionBar.setDisplayShowCustomEnabled(true); actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM); LayoutInflater inflator = (LayoutInflater) this .getSystemService(Context.LAYOUT_INFLATER_SERVICE); View v = inflator.inflate(layoutId, new LinearLayout(mContext), false); ActionBar.LayoutParams layout = new ActionBar.LayoutParams( ActionBar.LayoutParams.MATCH_PARENT, ActionBar.LayoutParams.MATCH_PARENT); actionBar.setCustomView(v, layout); netHistory = (Button) findViewById(R.id.net_history); netScan = (Button) findViewById(R.id.net_scan); netSetting = (Button) findViewById(R.id.net_setting); netScan.setOnClickListener(this); netHistory.setOnClickListener(this); netSetting.setOnClickListener(this); }else{ Toast.makeText(NetMediaActivty.this, "ActionBar不存在", Toast.LENGTH_SHORT).show(); } }
Example 5
Source File: MainActivity.java From KSYMediaPlayer_Android with Apache License 2.0 | 6 votes |
public void setActionBarLayout(int layoutId, Context mContext) { ActionBar actionBar = getSupportActionBar(); if (null != actionBar) { actionBar.setDisplayShowHomeEnabled(false); actionBar.setDisplayShowCustomEnabled(true); actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM); LayoutInflater inflator = (LayoutInflater) this .getSystemService(Context.LAYOUT_INFLATER_SERVICE); View v = inflator.inflate(layoutId, new LinearLayout(mContext), false); ActionBar.LayoutParams layout = new ActionBar.LayoutParams( ActionBar.LayoutParams.MATCH_PARENT, ActionBar.LayoutParams.MATCH_PARENT); actionBar.setCustomView(v, layout); media_net = (Button)findViewById(R.id.media_network); media_history = (Button)findViewById(R.id.media_history); media_setting = (Button)findViewById(R.id.media_setting); media_net.setOnClickListener(this); media_setting.setOnClickListener(this); media_history.setOnClickListener(this); }else{ Toast.makeText(MainActivity.this, "ActionBar不存在", Toast.LENGTH_SHORT).show(); } }
Example 6
Source File: PreferenceBase.java From Ansole with GNU General Public License v2.0 | 5 votes |
@SuppressWarnings("deprecation") @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.preference_activity); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); ActionBar ab = getSupportActionBar(); if (ab != null) { ab.setDisplayOptions(ActionBar.DISPLAY_HOME_AS_UP, ActionBar.DISPLAY_HOME_AS_UP); } }
Example 7
Source File: AnagramFragment.java From Anagram-Solver with MIT License | 5 votes |
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); ActionBar actionbar = ((MainActivity) getActivity()).getSupportActionBar(); actionbar.show(); actionbar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM); actionbar.setCustomView(R.layout.actionbar_view); }
Example 8
Source File: ActionBarTabs.java From V.FlyoutTest with MIT License | 5 votes |
public void onToggleTabs(View v) { final ActionBar bar = getSupportActionBar(); if (bar.getNavigationMode() == ActionBar.NAVIGATION_MODE_TABS) { bar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD); bar.setDisplayOptions(ActionBar.DISPLAY_SHOW_TITLE, ActionBar.DISPLAY_SHOW_TITLE); } else { bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); bar.setDisplayOptions(0, ActionBar.DISPLAY_SHOW_TITLE); } }
Example 9
Source File: RecyclerViewFragment.java From kernel_adiutor with Apache License 2.0 | 5 votes |
public void setProgressBar(ProgressBar progressBar) { progressBar.getIndeterminateDrawable().setColorFilter(new LightingColorFilter(0xFF000000, getResources().getColor(android.R.color.white))); ActionBar actionBar; if ((actionBar = getActionBar()) != null) { actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM, ActionBar.DISPLAY_SHOW_CUSTOM); actionBar.setCustomView(progressBar, new ActionBar.LayoutParams(ActionBar.LayoutParams.WRAP_CONTENT, ActionBar.LayoutParams.WRAP_CONTENT, Gravity.CENTER_VERTICAL | Gravity.END)); } }
Example 10
Source File: RecentAlbumsActivity.java From PainlessMusicPlayer with Apache License 2.0 | 5 votes |
@Override public void setSupportActionBar(@Nullable final Toolbar toolbar) { super.setSupportActionBar(toolbar); final ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_TITLE | ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_HOME_AS_UP); } }
Example 11
Source File: GenreAlbumsActivity.java From PainlessMusicPlayer with Apache License 2.0 | 5 votes |
@Override public void setSupportActionBar(@Nullable final Toolbar toolbar) { super.setSupportActionBar(toolbar); final ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_TITLE | ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_HOME_AS_UP); } }
Example 12
Source File: ArtistAlbumsActivity.java From PainlessMusicPlayer with Apache License 2.0 | 5 votes |
@Override public void setSupportActionBar(@Nullable final Toolbar toolbar) { super.setSupportActionBar(toolbar); final ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_TITLE | ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_HOME_AS_UP); } }
Example 13
Source File: QueueActivity.java From PainlessMusicPlayer with Apache License 2.0 | 5 votes |
@Override public void setSupportActionBar(@Nullable final Toolbar toolbar) { super.setSupportActionBar(toolbar); final ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_TITLE | ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_HOME_AS_UP); } }
Example 14
Source File: AudioEffectsActivity.java From PainlessMusicPlayer with Apache License 2.0 | 5 votes |
private void initActionBar() { final ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_TITLE | ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_HOME_AS_UP); } }
Example 15
Source File: SettingsActivity.java From PainlessMusicPlayer with Apache License 2.0 | 5 votes |
private void initActionBar() { final ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_TITLE | ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_HOME_AS_UP); } }
Example 16
Source File: NowPlayingActivity.java From PainlessMusicPlayer with Apache License 2.0 | 5 votes |
@Override public void setSupportActionBar(@Nullable final Toolbar toolbar) { super.setSupportActionBar(toolbar); final ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_TITLE | ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_HOME_AS_UP); } }
Example 17
Source File: RecyclerViewFragment.java From KA27 with Apache License 2.0 | 5 votes |
public void setProgressBar(ProgressBar progressBar) { progressBar.getIndeterminateDrawable().setColorFilter(new LightingColorFilter(0xFF000000, ContextCompat.getColor(getActivity(), android.R.color.white))); ActionBar actionBar; if ((actionBar = getActionBar()) != null) { actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM, ActionBar.DISPLAY_SHOW_CUSTOM); actionBar.setCustomView(progressBar, new ActionBar.LayoutParams(ActionBar.LayoutParams.WRAP_CONTENT, ActionBar.LayoutParams.WRAP_CONTENT, Gravity.CENTER_VERTICAL | Gravity.END)); } }
Example 18
Source File: ActionBarDisplayOptions.java From V.FlyoutTest with MIT License | 4 votes |
@Override public void onClick(View v) { final ActionBar bar = getSupportActionBar(); int flags = 0; switch (v.getId()) { case R.id.toggle_home_as_up: flags = ActionBar.DISPLAY_HOME_AS_UP; break; case R.id.toggle_show_home: flags = ActionBar.DISPLAY_SHOW_HOME; break; case R.id.toggle_use_logo: flags = ActionBar.DISPLAY_USE_LOGO; break; case R.id.toggle_show_title: flags = ActionBar.DISPLAY_SHOW_TITLE; break; case R.id.toggle_show_custom: flags = ActionBar.DISPLAY_SHOW_CUSTOM; break; case R.id.toggle_navigation: bar.setNavigationMode( bar.getNavigationMode() == ActionBar.NAVIGATION_MODE_STANDARD ? ActionBar.NAVIGATION_MODE_TABS : ActionBar.NAVIGATION_MODE_STANDARD); return; case R.id.cycle_custom_gravity: { ActionBar.LayoutParams lp = mCustomViewLayoutParams; int newGravity = 0; switch (lp.gravity & Gravity.HORIZONTAL_GRAVITY_MASK) { case Gravity.LEFT: newGravity = Gravity.CENTER_HORIZONTAL; break; case Gravity.CENTER_HORIZONTAL: newGravity = Gravity.RIGHT; break; case Gravity.RIGHT: newGravity = Gravity.LEFT; break; } lp.gravity = lp.gravity & ~Gravity.HORIZONTAL_GRAVITY_MASK | newGravity; bar.setCustomView(mCustomView, lp); return; } case R.id.toggle_visibility: if (bar.isShowing()) { bar.hide(); } else { bar.show(); } return; } int change = bar.getDisplayOptions() ^ flags; bar.setDisplayOptions(change, flags); }
Example 19
Source File: StyleUtils.java From IslamicLibraryAndroid with GNU General Public License v3.0 | 4 votes |
public static void configureFlatBlueActionBar(Context context, ActionBar actionBar) { setThemedActionBarDrawable(context, actionBar); actionBar.setDisplayOptions(14, 14); }