Java Code Examples for android.support.v7.app.ActionBar#setDisplayShowTitleEnabled()

The following examples show how to use android.support.v7.app.ActionBar#setDisplayShowTitleEnabled() . 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: ByWebViewActivity.java    From ByWebView with Apache License 2.0 6 votes vote down vote up
private void initToolBar() {
    // 可滚动的title 使用简单 没有渐变效果,文字两旁有阴影
    Toolbar mTitleToolBar = findViewById(R.id.title_tool_bar);
    tvGunTitle = findViewById(R.id.tv_gun_title);
    setSupportActionBar(mTitleToolBar);
    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        //去除默认Title显示
        actionBar.setDisplayShowTitleEnabled(false);
    }
    mTitleToolBar.setOverflowIcon(ContextCompat.getDrawable(this, R.drawable.actionbar_more));
    tvGunTitle.postDelayed(new Runnable() {
        @Override
        public void run() {
            tvGunTitle.setSelected(true);
        }
    }, 1900);
    tvGunTitle.setText(mTitle);
}
 
Example 2
Source File: OdooActivity.java    From framework with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * Actionbar Spinner handler
 */

public void setHasActionBarSpinner(Boolean hasActionBarSpinner) {
    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        Spinner spinner = (Spinner) findViewById(R.id.spinner_nav);
        if (hasActionBarSpinner) {
            if (spinner != null)
                spinner.setVisibility(View.VISIBLE);
            actionBar.setDisplayShowTitleEnabled(false);
        } else {
            if (spinner != null)
                spinner.setVisibility(View.GONE);
            actionBar.setDisplayShowTitleEnabled(true);
        }
        mHasActionBarSpinner = hasActionBarSpinner;
    }
}
 
Example 3
Source File: OrderDetailActivity.java    From nongbeer-mvp-android-demo with Apache License 2.0 6 votes vote down vote up
@SuppressLint( "SetTextI18n" )
@Override
public void setupView(){
    int itemSpace = (int) getResources().getDimension( R.dimen.default_padding_margin_large );
    rvOrder.addItemDecoration( new LinearLayoutMargin( itemSpace ) );
    rvOrder.setLayoutManager( new LinearLayoutManager( this ) );
    rvOrder.setAdapter( orderAdapter );
    btnClose.setOnClickListener( onClickBack() );
    btnBack.setOnClickListener( onClickBack() );

    setSupportActionBar( toolbar );
    ActionBar actionbar = getSupportActionBar();
    if( actionbar != null ){
        actionbar.setDisplayHomeAsUpEnabled( false );
        actionbar.setDisplayShowTitleEnabled( false );
    }

    tvDate.setText( item.getDate() + StringUtils.getAtString(this) + item.getTime() );
    tvTotalPrice.setText( StringUtils.getCommaPriceWithBaht( this, item.getTotalPrice() ) );
}
 
Example 4
Source File: BaseActivity.java    From ClockPlus with GNU General Public License v3.0 5 votes vote down vote up
@CallSuper
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // Initialize the associated SharedPreferences file with default values
    // for each preference when the user first opens your application.
    // When false, the system sets the default values only if this method has
    // never been called in the past (or the KEY_HAS_SET_DEFAULT_VALUES in the
    // default value shared preferences file is false).
    PreferenceManager.setDefaultValues(this, R.xml.preferences, false);
    // ========================================================================================
    // TOneverDO: Set theme after setContentView()
    final String themeDark = getString(R.string.theme_dark);
    final String themeBlack = getString(R.string.theme_black);
    String theme = PreferenceManager.getDefaultSharedPreferences(this).getString(
            getString(R.string.key_theme), null);
    if (themeDark.equals(theme)) {
        setTheme(R.style.AppTheme_Dark);
    } else if (themeBlack.equals(theme)) {
        setTheme(R.style.AppTheme_Black);
    }
    // ========================================================================================
    setContentView(layoutResId());
    // Direct volume changes to the alarm stream
    setVolumeControlStream(AudioManager.STREAM_ALARM);
    ButterKnife.bind(this);
    if (mToolbar != null) {
        setSupportActionBar(mToolbar);
        ActionBar ab = getSupportActionBar();
        if (ab != null) {
            ab.setDisplayHomeAsUpEnabled(isDisplayHomeUpEnabled());
            ab.setDisplayShowTitleEnabled(isDisplayShowTitleEnabled());
        }
    }
}
 
Example 5
Source File: NavigationDrawerFragment.java    From RedEnvelopeAssistant with MIT License 5 votes vote down vote up
/**
 * Per the navigation drawer design guidelines, updates the action bar to
 * show the global app 'context', rather than just what's in the current
 * screen.
 */
private void showGlobalContextActionBar() {
	ActionBar actionBar = getActionBar();
	actionBar.setDisplayShowTitleEnabled(true);
	actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
	actionBar.setTitle(R.string.app_name);
}
 
Example 6
Source File: NavigationDrawerFragment.java    From android-overlay-protection with Apache License 2.0 5 votes vote down vote up
/**
 * Per the navigation drawer design guidelines, updates the action bar to show the global app
 * 'context', rather than just what's in the current screen.
 */
private void showGlobalContextActionBar() {
    ActionBar actionBar = getActionBar();
    actionBar.setDisplayShowTitleEnabled(true);
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
    actionBar.setTitle(R.string.app_name);
}
 
Example 7
Source File: SecurityCodeActivity.java    From px-android with MIT License 5 votes vote down vote up
private void initializeToolbar() {
    mToolbar = findViewById(R.id.mpsdkToolbar);
    setSupportActionBar(mToolbar);
    final ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setDisplayShowTitleEnabled(false);
        actionBar.setDisplayShowTitleEnabled(false);
        actionBar.setDisplayHomeAsUpEnabled(true);
        actionBar.setDisplayShowHomeEnabled(true);
        actionBar.setHomeActionContentDescription(R.string.px_label_back);
    }
    mToolbar.setNavigationOnClickListener(v -> onBackPressed());
}
 
Example 8
Source File: WebViewActivity.java    From droidkaigi2016 with Apache License 2.0 5 votes vote down vote up
private void initToolbar(@NonNull String title) {
    setSupportActionBar(binding.toolbar);

    ActionBar bar = getSupportActionBar();
    if (bar != null) {
        bar.setDisplayHomeAsUpEnabled(true);
        bar.setDisplayShowHomeEnabled(true);
        bar.setDisplayShowTitleEnabled(false);
        bar.setHomeButtonEnabled(true);
    }
    binding.toolbar.setTitle(title);
}
 
Example 9
Source File: MainActivity.java    From DanDanPlayForAndroid with MIT License 5 votes vote down vote up
@Override
public void initView() {
    if (hasBackActionbar() && getSupportActionBar() != null) {
        ActionBar actionBar = getSupportActionBar();
        actionBar.setDisplayHomeAsUpEnabled(false);
        actionBar.setDisplayShowTitleEnabled(true);
    }
    setTitle("媒体库");
    navigationView.setSelectedItemId(R.id.navigation_play);
    switchFragment(PlayFragment.class);

    initPermission();
}
 
Example 10
Source File: MainActivity.java    From Yahala-Messenger with MIT License 5 votes vote down vote up
@Override
public void applySelfActionBar() {
    try {
        if (parentActivity == null) {
            return;
        }
        final ActionBar actionBar = parentActivity.getSupportActionBar();
        //  actionBar.hide();
        //ImageView view = (ImageView) fragmentView.findViewById(16908332);
        // if (view == null) {
        ImageView view = (ImageView) fragmentView.findViewById(R.id.home);
        // }
        if (view != null) {
            view.setPadding(OSUtilities.dp(6), 0, OSUtilities.dp(6), 0);
        }
        actionBar.setDisplayShowTitleEnabled(true);
        actionBar.setDisplayShowHomeEnabled(true);
        actionBar.setDisplayHomeAsUpEnabled(false);
        actionBar.setDisplayUseLogoEnabled(false);

        actionBar.setCustomView(null);
        actionBar.setSubtitle(null);
        actionBar.setTitle(LocaleController.getString("AppName", R.string.AppName));

    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
Example 11
Source File: SummaryView.java    From px-android with MIT License 5 votes vote down vote up
public void configureToolbar(@NonNull final AppCompatActivity activity,
    @NonNull final View.OnClickListener listener) {
    final Toolbar toolbar = findViewById(R.id.toolbar);
    activity.setSupportActionBar(toolbar);

    final ActionBar actionBar = activity.getSupportActionBar();
    if (actionBar != null) {
        actionBar.setDisplayShowTitleEnabled(false);
        actionBar.setDisplayHomeAsUpEnabled(true);
        actionBar.setDisplayShowHomeEnabled(true);
        actionBar.setHomeButtonEnabled(true);
        actionBar.setHomeActionContentDescription(R.string.px_label_back);
    }
    toolbar.setNavigationOnClickListener(listener);
}
 
Example 12
Source File: MainActivity.java    From android-player with Apache License 2.0 5 votes vote down vote up
private void initDrawerLayout() {
    final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    final ActionBar supportActionBar = getSupportActionBar();
    final DrawerLayout drawerLayout = (DrawerLayout) findViewById(R.id.activityMainDrawerLayout);
    final ActionBarDrawerToggle drawerToggle = new ActionBarDrawerToggle(this, drawerLayout, R.string.abc_toolbar_collapse_description,
            R.string.abc_toolbar_collapse_description);
    drawerToggle.setDrawerIndicatorEnabled(true);
    supportActionBar.setDisplayHomeAsUpEnabled(true);
    supportActionBar.setHomeButtonEnabled(true);
    supportActionBar.setDisplayShowTitleEnabled(false);
    drawerToggle.syncState();
    drawerLayout.setDrawerListener(drawerToggle);
}
 
Example 13
Source File: CodePreviewActivity.java    From actor-platform with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    text = getIntent().getStringExtra("source_code");

    ActionBar actionBar = getSupportActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);
    actionBar.setDisplayShowHomeEnabled(false);
    actionBar.setDisplayHomeAsUpEnabled(true);
    actionBar.setDisplayShowTitleEnabled(true);
    actionBar.setDisplayShowCustomEnabled(false);

    actionBar.setTitle("Code Preview");

    WebView webView = new WebView(this);
    webView.getSettings().setJavaScriptEnabled(true);

    String data = "<html>\n" +
            "<header>\n" +
            "<link rel=\"stylesheet\" href=\"highlight-default.min.css\">\n" +
            "<script src=\"highlight.min.js\"></script>\n" +
            "<script>hljs.initHighlightingOnLoad();</script>\n" +
            "</header>\n" +
            "<body>\n" +
            "<pre><code>" +
            text.replace("&", "&amp;")
                    .replace("<", "&lt;")
                    .replace(">", "&gt;")
                    .replace("\"", "&quot;")
                    .replace("\n", "<br/>")
            + "</code></pre>" +
            "</body>\n" +
            "</html>";

    webView.loadDataWithBaseURL("file:///android_asset/", data, "text/html", "utf-8", "");

    setContentView(webView);
}
 
Example 14
Source File: SettingsActivity.java    From ForPDA with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    currentThemeIsDark = App.get().isDarkTheme();
    setTheme(currentThemeIsDark ? R.style.PreferenceAppThemeDark : R.style.PreferenceAppThemeLight);
    setContentView(R.layout.activity_settings);

    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setHomeButtonEnabled(true);
        actionBar.setDisplayHomeAsUpEnabled(true);
        actionBar.setDisplayShowTitleEnabled(true);
        actionBar.setTitle(R.string.activity_title_settings);
    }
    PreferenceFragmentCompat fragment = null;
    Intent intent = getIntent();
    if (intent != null) {
        String settingsArgument = intent.getStringExtra(ARG_NEW_PREFERENCE_SCREEN);
        if (settingsArgument != null) {
            if (settingsArgument.equals(NotificationsSettingsFragment.PREFERENCE_SCREEN_NAME)) {
                fragment = new NotificationsSettingsFragment();
            }
        }
    }
    if (fragment == null) {
        fragment = new SettingsFragment();
    }

    getSupportFragmentManager().beginTransaction().replace(R.id.fragment_content, fragment).commit();

    /*View view = findViewById(R.id.fragment_content);
    view.setBackgroundColor(Color.TRANSPARENT);
    view.setBackgroundColor(Color.rgb(4, 26, 55));*/

    App.get().addPreferenceChangeObserver(appThemeChangeObserver);
}
 
Example 15
Source File: CollectionActivity.java    From Yuan-WanAndroid with Apache License 2.0 5 votes vote down vote up
@Override
public void initToolbar() {
    setSupportActionBar(mCommonToolbar);
    mToolbarTitle.setText(getString(R.string.person_collection));
    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);
        actionBar.setDisplayShowTitleEnabled(false);//不使用原始的toolbar的title
    }
    mCommonToolbar.setNavigationOnClickListener(v -> {
        //如果有进行取消收藏的操作,退出时将更新文章
        if (isUnCollect) RxBus.getInstance().post(new AutoRefreshEvent(true));
        finish();
    });
}
 
Example 16
Source File: MainActivity.java    From android-overlay-protection with Apache License 2.0 5 votes vote down vote up
public void restoreActionBar() {
    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setDisplayShowTitleEnabled(true);
        actionBar.setTitle(mTitle);
        actionBar.setDisplayShowHomeEnabled(true);
        actionBar.setIcon(R.drawable.ic_launcher_transparent);
    }
}
 
Example 17
Source File: DropdownProxy.java    From actionbarextras with MIT License 4 votes vote down vote up
private void handleRemove(){
	ActionBar actionBar = ((AppCompatActivity)getActivity()).getSupportActionBar();
	actionBar.setDisplayShowTitleEnabled(true);
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
}
 
Example 18
Source File: NavigationDrawerFragment.java    From Woodmin with Apache License 2.0 4 votes vote down vote up
private void showGlobalContextActionBar() {
    ActionBar actionBar = getActionBar();
    actionBar.setDisplayShowTitleEnabled(true);
    //actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
    actionBar.setTitle(R.string.app_name);
}
 
Example 19
Source File: MainActivity.java    From jus with Apache License 2.0 4 votes vote down vote up
public void restoreActionBar() {
    ActionBar actionBar = getSupportActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
    actionBar.setDisplayShowTitleEnabled(true);
    actionBar.setTitle(mTitle);
}
 
Example 20
Source File: MainActivity.java    From droidddle with Apache License 2.0 4 votes vote down vote up
public void restoreActionBar() {
    ActionBar actionBar = getSupportActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
    actionBar.setDisplayShowTitleEnabled(true);
    actionBar.setTitle(mTitle);
}