当前位置: 首页>>代码示例>>Java>>正文


Java ActionBar.setDisplayShowCustomEnabled方法代码示例

本文整理汇总了Java中android.support.v7.app.ActionBar.setDisplayShowCustomEnabled方法的典型用法代码示例。如果您正苦于以下问题:Java ActionBar.setDisplayShowCustomEnabled方法的具体用法?Java ActionBar.setDisplayShowCustomEnabled怎么用?Java ActionBar.setDisplayShowCustomEnabled使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.support.v7.app.ActionBar的用法示例。


在下文中一共展示了ActionBar.setDisplayShowCustomEnabled方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: handleMenuSearch

import android.support.v7.app.ActionBar; //导入方法依赖的package包/类
private void handleMenuSearch() {
    ActionBar supportActionBar = getSupportActionBar();

    if (isSearchOpened) {
        disableSearch(supportActionBar);
    } else {

        supportActionBar.setDisplayShowCustomEnabled(true);
        supportActionBar.setCustomView(R.layout.search_bar);
        supportActionBar.setDisplayShowTitleEnabled(false);

        termsSearch = (EditText) supportActionBar.getCustomView().findViewById(R.id.terms_search);

        termsSearch.setOnEditorActionListener((view, id, event) -> {
            if (id == EditorInfo.IME_ACTION_SEARCH) {
                doSearch(termsSearch.getText().toString());
                disableSearch(supportActionBar);
                return true;
            }
            return false;
        });

        termsSearch.requestFocus();

        InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
        imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);

        mSearchAction.setIcon(getResources().getDrawable(R.mipmap.ic_clear_white_24dp, null));

        isSearchOpened = true;
    }
}
 
开发者ID:rsetkus,项目名称:rx-twitter-stream-android,代码行数:33,代码来源:StreamActivity.java

示例2: disableSearch

import android.support.v7.app.ActionBar; //导入方法依赖的package包/类
private void disableSearch(ActionBar action) {
    action.setDisplayShowCustomEnabled(false);
    action.setDisplayShowTitleEnabled(true);

    termsSearch.clearFocus();
    InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);

    mSearchAction.setIcon(getResources().getDrawable(R.mipmap.ic_search_white_24dp, null));

    isSearchOpened = false;
}
 
开发者ID:rsetkus,项目名称:rx-twitter-stream-android,代码行数:13,代码来源:StreamActivity.java

示例3: setUpCustomToolbar

import android.support.v7.app.ActionBar; //导入方法依赖的package包/类
/**
 * This should be called after the content view has been added in onCreate()
 *
 * @param ownLayout true if the custom toolbar brings its own layout
 * @return the Toolbar object or null if content view did not contain one
 */
@Nullable
protected Toolbar setUpCustomToolbar(boolean ownLayout) {
	// Custom Toolbar
	Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
	setSupportActionBar(toolbar);
	ActionBar ab = getSupportActionBar();
	if (ab != null) {
		ab.setDisplayShowHomeEnabled(true);
		ab.setDisplayHomeAsUpEnabled(true);
		ab.setDisplayShowCustomEnabled(ownLayout);
		ab.setDisplayShowTitleEnabled(!ownLayout);
	}
	return toolbar;
}
 
开发者ID:rafjordao,项目名称:Nird2,代码行数:21,代码来源:BriarActivity.java

示例4: hideSearchView

import android.support.v7.app.ActionBar; //导入方法依赖的package包/类
@SuppressWarnings("ConstantConditions")
private void hideSearchView() {
    final ActionBar actionBar = getSupportActionBar();
    final android.support.v7.widget.Toolbar toolbar =
            (android.support.v7.widget.Toolbar) actionBar.getCustomView().getParent();

    final EditText searchEditText = actionBar.getCustomView()
            .findViewById(R.id.ActivityMainSearchEditText);

    if (!TextUtils.isEmpty(searchEditText.getText().toString())) {
        searchEditText.setText(null);

        SoftInputUtils.forceShowSoftInput(this, toolbar);
    } else {
        final List<Integer> ids = Arrays.asList(R.attr.colorPrimary,
                R.attr.colorPrimaryDark);

        TypedValueUtils.resolveResourceIds(MainActivity.this, ids);

        setActionBarColor(ids.get(0));
        setStatusBarColor(ids.get(1));

        toggleSystemUiVisibility(true);

        toolbar.setContentInsetsAbsolute(mActionBarInsets[0], mActionBarInsets[1]);

        SoftInputUtils.dismissSoftInput(this, toolbar);

        actionBar.setCustomView(null);
        actionBar.setDisplayShowCustomEnabled(false);

        actionBar.setDisplayShowTitleEnabled(true);

        invalidateOptionsMenu();
    }
}
 
开发者ID:Applications-Development,项目名称:SimpleRssReader,代码行数:37,代码来源:MainActivity.java

示例5: onCreate

import android.support.v7.app.ActionBar; //导入方法依赖的package包/类
@Override
    protected void onCreate(Bundle savedInstanceState) {
        ((IslamicLibraryApplication) getApplication()).refreshLocale(this, false);
        super.onCreate(savedInstanceState);

        // Enable if you use AppCompat 24.1.x.
//        Fixes.updateLayoutInflaterFactory(getLayoutInflater());

        setContentView(R.layout.activity_settings);

        mReplaceFragmentStrategy = new PreferenceScreenNavigationStrategy
                .ReplaceFragment(this,
                R.anim.abc_fade_in,
                R.anim.abc_fade_out,
                R.anim.abc_fade_in,
                R.anim.abc_fade_out);

        if (savedInstanceState == null) {
            mSettingsFragment = SettingsFragment.newInstance(null);
            getSupportFragmentManager().beginTransaction().add(R.id.content, mSettingsFragment, "Settings").commit();
        } else {
            mSettingsFragment = (SettingsFragment) getSupportFragmentManager().findFragmentByTag("Settings");
        }

        getSupportFragmentManager().addOnBackStackChangedListener(this);

        mToolbar = findViewById(R.id.toolbar);
        setSupportActionBar(mToolbar);
        ActionBar ab = getSupportActionBar();


        // Cross-fading title setup.
        mTitle = getTitle();

        mTitleSwitcher = new TextSwitcher(mToolbar.getContext());
        mTitleSwitcher.setFactory(() -> {
            TextView tv = new AppCompatTextView(mToolbar.getContext());
            TextViewCompat.setTextAppearance(tv, R.style.TextAppearance_AppCompat_Widget_ActionBar_Title);
            return tv;
        });
        mTitleSwitcher.setCurrentText(mTitle);
        if (ab != null) {
            ab.setDisplayHomeAsUpEnabled(true);
            ab.setCustomView(mTitleSwitcher);
            ab.setDisplayShowCustomEnabled(true);
            ab.setDisplayShowTitleEnabled(false);
        }


        // Add to hierarchy before accessing layout params.
        int margin = Util.dpToPxOffset(this, 16);
        ViewGroup.MarginLayoutParams lp = (ViewGroup.MarginLayoutParams) mTitleSwitcher.getLayoutParams();
        lp.leftMargin = margin;
        lp.rightMargin = margin;

        mTitleSwitcher.setInAnimation(this, R.anim.abc_fade_in);
        mTitleSwitcher.setOutAnimation(this, R.anim.abc_fade_out);
    }
 
开发者ID:fekracomputers,项目名称:IslamicLibraryAndroid,代码行数:59,代码来源:SettingsActivity.java


注:本文中的android.support.v7.app.ActionBar.setDisplayShowCustomEnabled方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。