Java Code Examples for android.app.ActionBar#setDisplayShowCustomEnabled()

The following examples show how to use android.app.ActionBar#setDisplayShowCustomEnabled() . 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: SearchActivity.java    From java-unified-sdk with Apache License 2.0 6 votes vote down vote up
@SuppressLint("NewApi")
private void setupActionBar() {
    ActionBar actionBar = getActionBar();
    if (actionBar != null) {
        actionBar.setCustomView(Resources.layout.search_actionbar(this));
        actionBar.setDisplayShowCustomEnabled(true);
        actionBar.setDisplayShowHomeEnabled(false);
        actionBar.setDisplayShowTitleEnabled(false);
        View backButton =
            actionBar.getCustomView()
                .findViewById(Resources.id.search_actionbar_back(this));
        backButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                onBackPressed();
                finish();
            }
        });
    }
}
 
Example 2
Source File: MainListFragment.java    From Android-Applications-Info with Apache License 2.0 6 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setHasOptionsMenu(true);
    mProgressDialog = new ProgressDialog(mActivity);
    mProgressDialog.setTitle(R.string.loading_apps);
    mProgressDialog.setCancelable(false);

    ActionBar actionBar = getActivity().getActionBar();
    actionBar.setDisplayShowCustomEnabled(true);

    SearchView searchView = new SearchView(actionBar.getThemedContext());
    searchView.setOnQueryTextListener(this);

    ActionBar.LayoutParams layoutParams = new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT);
    actionBar.setCustomView(searchView, layoutParams);

    if (savedInstanceState != null) {
        int sortBy = savedInstanceState.getInt(INSTANCE_STATE_SORT_BY, -1);
        if (sortBy != -1)
            setSortBy(sortBy);
    }
}
 
Example 3
Source File: MSS.java    From MainScreenShow with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 设置ActionBar的布局
 *
 * @param layoutId 布局Id
 */
public void setActionBarLayout(int layoutId) {
    ActionBar actionBar = getActionBar();
    if (null != actionBar) {
        actionBar.setDisplayShowHomeEnabled(false);
        actionBar.setDisplayShowCustomEnabled(true);
        actionBar.setDisplayShowTitleEnabled(false);
        actionBar.setDisplayHomeAsUpEnabled(false);
        actionBar.setDisplayUseLogoEnabled(false);

        LayoutInflater inflator = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View v = inflator.inflate(layoutId, null);
        ActionBar.LayoutParams layout = new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
        actionBar.setCustomView(v, layout);
    }
}
 
Example 4
Source File: BreadcrumbBarFragment.java    From commcare-android with Apache License 2.0 5 votes vote down vote up
private void attachBreadcrumbBar(Activity activity, ActionBar actionBar) {
    //make sure we're in the right mode
    actionBar.setDisplayShowCustomEnabled(true);
    actionBar.setDisplayShowTitleEnabled(false);

    //We need to get the amount that each item should "bleed" over to the left, and move the whole widget that
    //many pixels. This replicates the "overlap" space that each piece of the bar has on the next piece for
    //the left-most element.
    int buffer = Math.round(activity.getResources().getDimension(R.dimen.title_round_bleed));
    LayoutParams p = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
    p.leftMargin = buffer;

    activity.setTitle("");
    actionBar.setDisplayShowHomeEnabled(false);
}
 
Example 5
Source File: DialtactsActivity.java    From coursera-android with MIT License 5 votes vote down vote up
/**
 * Goes back to usual Phone UI with tags. Previously selected Tag and associated Fragment
 * should be automatically focused again.
 */
private void exitSearchUi() {
    final ActionBar actionBar = getActionBar();

    // Hide the search fragment, if exists.
    if (mSearchFragment != null) {
        mSearchFragment.setUserVisibleHint(false);

        final FragmentTransaction transaction = getFragmentManager().beginTransaction();
        transaction.hide(mSearchFragment);
        transaction.commitAllowingStateLoss();
    }

    // We want to hide SearchView and show Tabs. Also focus on previously selected one.
    actionBar.setDisplayShowCustomEnabled(false);
    actionBar.setDisplayShowHomeEnabled(false);
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

    for (int i = 0; i < TAB_INDEX_COUNT; i++) {
        sendFragmentVisibilityChange(i, i == mViewPager.getCurrentItem());
    }

    // Before exiting the search screen, reset swipe state.
    mDuringSwipe = false;
    mUserTabClick = false;

    mViewPager.setVisibility(View.VISIBLE);

    hideInputMethod(getCurrentFocus());

    // Request to update option menu.
    invalidateOptionsMenu();

    // See comments in onActionViewExpanded()
    mSearchView.onActionViewCollapsed();
    mInSearchUi = false;
}
 
Example 6
Source File: PhotoViewerActivity.java    From glimmr with Apache License 2.0 5 votes vote down vote up
public void init(ActionBar actionbar) {
    LayoutInflater inflator = (LayoutInflater)
        mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View v = inflator.inflate(R.layout.photoviewer_action_bar, null);
    mPhotoTitle = (TextView) v.findViewById(R.id.photoTitle);
    mPhotoAuthor = (TextView) v.findViewById(R.id.photoAuthor);
    mTextUtils.setFont(mPhotoTitle, TextUtils.FONT_ROBOTOLIGHT);
    mTextUtils.setFont(mPhotoAuthor, TextUtils.FONT_ROBOTOTHIN);
    actionbar.setDisplayShowCustomEnabled(true);
    actionbar.setDisplayShowTitleEnabled(false);
    actionbar.setCustomView(v);
}
 
Example 7
Source File: GlimmrAbCustomTitle.java    From glimmr with Apache License 2.0 5 votes vote down vote up
public void init(ActionBar actionbar) {
    LayoutInflater inflator = (LayoutInflater)
        mActivity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View v = inflator.inflate(R.layout.action_bar_title_item, null);
    TextView abTitle = (TextView) v.findViewById(R.id.abTitle);
    mTextUtils.setFont(abTitle, TextUtils.FONT_SHADOWSINTOLIGHT);
    abTitle.setText(mActivity.getString(R.string.app_name));
    actionbar.setDisplayShowCustomEnabled(true);
    actionbar.setDisplayShowTitleEnabled(false);
    actionbar.setCustomView(v);
}
 
Example 8
Source File: EnvelopeDetailsFragment.java    From budget-envelopes with GNU General Public License v3.0 5 votes vote down vote up
@Override public void onDestroy() {
    super.onDestroy();
    ActionBar ab = getActivity().getActionBar();
    ab.setDisplayShowTitleEnabled(true);
    ab.setDisplayShowCustomEnabled(false);
    ab.setCustomView(null);
    if (mName != null && mName.getText().length() == 0 && mLogAdapter != null && mLogAdapter.getCount() == 0 && mEnvelopeData != null && mLogData != null) {
        deleteThis();
        mDatabase.close();
        mDatabase = null;
    }
}
 
Example 9
Source File: PaycheckFragment.java    From budget-envelopes with GNU General Public License v3.0 5 votes vote down vote up
@Override public View onCreateActionBarView(LayoutInflater inflater) {
    ActionBar ab = getActivity().getActionBar();
    ab.setDisplayShowTitleEnabled(false);
    ab.setDisplayShowCustomEnabled(true);
    ab.setCustomView(R.layout.paycheckactivity_income);
    mIncome = (EditMoney) ab.getCustomView().findViewById(R.id.amount);
    mIncome.setCents(mIncomeValue);
    mIncome.addTextChangedListener(this);
    mDescription = (EditText) ab.getCustomView().findViewById(R.id.description);
    return ab.getCustomView();
}
 
Example 10
Source File: TestActivity.java    From codeexamples-android with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.main);
	ActionBar actionBar = getActionBar();
	actionBar.setCustomView(R.layout.actionbar_view);
	actionBar.setDisplayShowCustomEnabled(true);
}
 
Example 11
Source File: MainActivity.java    From kylewbanks.com-AndroidApp with The Unlicense 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    //Customize the action bar
    ActionBar actionBar = getActionBar();
    if(actionBar != null) {
        actionBar.setDisplayShowHomeEnabled(false);
        actionBar.setDisplayShowTitleEnabled(false);
        actionBar.setDisplayShowCustomEnabled(true);

        LayoutInflater inflater = (LayoutInflater)this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View v = inflater.inflate(R.layout.header, null);

        Typeface scriptFont = Typeface.createFromAsset(getAssets(), "fonts/script.ttf");
        TextView title = (TextView) v.findViewById(R.id.title);
        title.setTypeface(scriptFont);

        actionBar.setCustomView(v);
    }

    //Initialize Views
    postListView = (AnimatedListView) findViewById(R.id.post_list);
    postListView.setOnItemClickListener(postItemSelectedListener);


    progressBar = (ProgressBar) findViewById(R.id.loader);

    //Register as a Post List update listener
    KWBApplication application = (KWBApplication) getApplication();
    application.registerPostUpdateListener(this);
}
 
Example 12
Source File: DialtactsActivity.java    From coursera-android with MIT License 4 votes vote down vote up
/**
 * Hides every tab and shows search UI for phone lookup.
 */
private void enterSearchUi() {
    if (mSearchFragment == null) {
        // We add the search fragment dynamically in the first onLayoutChange() and
        // mSearchFragment is set sometime later when the fragment transaction is actually
        // executed, which means there's a window when users are able to hit the (physical)
        // search key but mSearchFragment is still null.
        // It's quite hard to handle this case right, so let's just ignore the search key
        // in this case.  Users can just hit it again and it will work this time.
        return;
    }
    if (mSearchView == null) {
        prepareSearchView();
    }

    final ActionBar actionBar = getActionBar();

    final Tab tab = actionBar.getSelectedTab();

    // User can search during the call, but we don't want to remember the status.
    if (tab != null && !DialpadFragment.phoneIsInUse()) {
        mLastManuallySelectedFragment = tab.getPosition();
    }

    mSearchView.setQuery(null, true);

    actionBar.setDisplayShowCustomEnabled(true);
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
    actionBar.setDisplayShowHomeEnabled(true);
    actionBar.setDisplayHomeAsUpEnabled(true);

    updateFakeMenuButtonsVisibility(false);

    for (int i = 0; i < TAB_INDEX_COUNT; i++) {
        sendFragmentVisibilityChange(i, false /* not visible */ );
    }

    // Show the search fragment and hide everything else.
    mSearchFragment.setUserVisibleHint(true);
    final FragmentTransaction transaction = getFragmentManager().beginTransaction();
    transaction.show(mSearchFragment);
    transaction.commitAllowingStateLoss();
    mViewPager.setVisibility(View.GONE);

    // We need to call this and onActionViewCollapsed() manually, since we are using a custom
    // layout instead of asking the search menu item to take care of SearchView.
    mSearchView.onActionViewExpanded();
    mInSearchUi = true;
}
 
Example 13
Source File: Settings.java    From Hangar with GNU General Public License v3.0 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mInstance = this;

    setContentView(R.layout.activity_settings);

    prefs = new PrefsGet(getSharedPreferences(getPackageName(), Context.MODE_MULTI_PROCESS));

    mContext = this;
    mIsLollipop = Tools.isLollipop(true);
    mIsAtLeastLollipop = Tools.isLollipop(false);

    if (showChangelog(prefs)) {
        launchChangelog();
    }

    if (mIsAtLeastLollipop && needsUsPermission()) {
        launchUsPermission(mContext);
    }

    display = getWindowManager().getDefaultDisplay();
    updateDisplayWidth();

    myService = new ServiceCall(mContext);
    myService.setConnection(mConnection);

    // Set up the action bar.
    final ActionBar actionBar = getActionBar();

    actionBar.setTitle(R.string.title_activity_settings);
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    actionBar.setCustomView(R.layout.action_spinner);
    setUpSpinner((Spinner) actionBar.getCustomView().findViewById(R.id.config_spinner));
    actionBar.setDisplayShowCustomEnabled(true);


    mSectionsPagerAdapter = new SectionsPagerAdapter(getFragmentManager());

    // Set up the ViewPager with the sections adapter.
    mViewPager = (ViewPager) findViewById(R.id.pager);
    mViewPager.setAdapter(mSectionsPagerAdapter);
    mViewPager.setOffscreenPageLimit(4);

    mGetFragments = new GetFragments();
    mGetFragments.setFm(getFragmentManager());
    mGetFragments.setVp(mViewPager);

    ViewPager.OnPageChangeListener pageChangeListener = new ViewPager.SimpleOnPageChangeListener() {
        @Override
        public void onPageSelected(int position) {
            actionBar.setSelectedNavigationItem(position);
        }
    };

    mViewPager.setOnPageChangeListener(pageChangeListener);

    for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) {
        actionBar.addTab(
                actionBar.newTab()
                        .setText(mSectionsPagerAdapter.getPageTitle(i))
                        .setTabListener(this));
    }
    pageChangeListener.onPageSelected(GENERAL_TAB);

}
 
Example 14
Source File: PostActivity.java    From Onosendai with Apache License 2.0 4 votes vote down vote up
@Override
protected void onCreate (final Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.post);

	Collection<Account> accounts;
	try {
		this.prefs = new Prefs(getBaseContext());
		accounts = this.prefs.readAccounts();
		this.conf = this.prefs.asConfig();
	}
	catch (final Exception e) { // No point continuing if any exception.
		DialogHelper.alertAndClose(this, e);
		return;
	}

	this.imageCache = new HybridBitmapCache(getBaseContext(), C.MAX_MEMORY_IMAGE_CACHE);
	this.exec = ExecUtils.newBoundedCachedThreadPool(C.NET_MAX_THREADS, LOG);

	this.intentExtras = getIntent().getExtras();
	if (this.intentExtras != null) {
		this.inReplyToUid = this.intentExtras.getLong(ARG_IN_REPLY_TO_UID);
		this.inReplyToSid = this.intentExtras.getString(ARG_IN_REPLY_TO_SID);
		this.altReplyToSid = this.intentExtras.getString(ARG_ALT_REPLY_TO_SID);
		this.mentions = this.intentExtras.getStringArray(ARG_MENTIONS);

		final long outboxUidOrDefault = this.intentExtras.getLong(ARG_OUTBOX_UID, -1);
		if (outboxUidOrDefault >= 0) this.outboxUid = outboxUidOrDefault;
	}
	LOG.i("inReplyToUid=%d inReplyToSid=%s altReplyToSid=%s mentions=%s outboxUid=%s",
			this.inReplyToUid, this.inReplyToSid, this.altReplyToSid, Arrays.toString(this.mentions), this.outboxUid);

	final ActionBar ab = getActionBar();
	ab.setDisplayHomeAsUpEnabled(true);
	ab.setDisplayShowTitleEnabled(false);
	ab.setDisplayShowCustomEnabled(true);

	this.spnAccount = new Spinner(ab.getThemedContext());
	this.spnAccount.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT));
	this.spnAccount.setPadding(0, 0, 0, 0);
	ab.setCustomView(this.spnAccount);

	setupAccounts(savedInstanceState, accounts, this.conf);

	setupAttachemnt(savedInstanceState);
	setupTextBody();
}
 
Example 15
Source File: MainActivity.java    From Onosendai with Apache License 2.0 4 votes vote down vote up
@Override
protected void onCreate (final Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);

	this.prefs = new Prefs(getBaseContext());
	if (!this.prefs.isConfigured()) {
		startActivity(new Intent(getApplicationContext(), SetupActivity.class));
		finish();
		return;
	}
	this.prefs.getSharedPreferences().registerOnSharedPreferenceChangeListener(this);

	requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
	setContentView(R.layout.activity_main);

	try {
		this.conf = this.prefs.asConfig();
	}
	catch (final Exception e) { // No point continuing if any exception.
		LOG.wtf("Unparsable config.", e);
		DialogHelper.alertAndClose(this, e);
		return;
	}

	this.imageCache = new HybridBitmapCache(this, C.MAX_MEMORY_IMAGE_CACHE);

	if (this.prefs.getSharedPreferences().getBoolean(AdvancedPrefFragment.KEY_THREAD_INSPECTOR, false)) {
		final TextView jobStatus = (TextView) findViewById(R.id.jobStatus);
		jobStatus.setVisibility(View.VISIBLE);
		this.executorStatus = new ExecutorStatus(jobStatus);
	}

	this.localEs = ExecUtils.newBoundedCachedThreadPool(C.LOCAL_MAX_THREADS, new LogWrapper("LES"), this.executorStatus);
	this.netEs = ExecUtils.newBoundedCachedThreadPool(C.NET_MAX_THREADS, new LogWrapper("NES"), this.executorStatus);
	this.msgHandler = new MessageHandler(this);

	final float columnWidth = UiPrefFragment.readColumnWidth(this, this.prefs);
	this.columnsRtl = UiPrefFragment.readColumnsRtl(this.prefs);

	// If this becomes too memory intensive, switch to android.support.v4.app.FragmentStatePagerAdapter.
	final SectionsPagerAdapter sectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager(), this, columnWidth);
	this.viewPager = (SidebarAwareViewPager) findViewById(R.id.pager);
	this.pageSelectionListener = new VisiblePageSelectionListener(columnWidth);
	final MultiplexingOnPageChangeListener onPageChangeListener = new MultiplexingOnPageChangeListener(
			this.pageSelectionListener,
			new NotificationClearingPageSelectionListener(this));
	this.viewPager.setOnPageChangeListener(onPageChangeListener);
	this.viewPager.setAdapter(sectionsPagerAdapter);
	if (!showPageFromIntent(getIntent())) {
		if (this.columnsRtl) {
			gotoPage(0);
		}
		else {
			onPageChangeListener.onPageSelected(this.viewPager.getCurrentItem());
		}
	}

	final ActionBar ab = getActionBar();
	ab.setDisplayShowHomeEnabled(true);
	ab.setHomeButtonEnabled(true);
	ab.setDisplayShowTitleEnabled(false);
	ab.setDisplayShowCustomEnabled(true);

	this.columnTitleStrip = new ColumnTitleStrip(ab.getThemedContext());
	this.columnTitleStrip.setViewPager(this.viewPager);
	this.columnTitleStrip.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
	this.columnTitleStrip.setColumnClickListener(new TitleClickListener(this));
	ab.setCustomView(this.columnTitleStrip);

	AlarmReceiver.configureAlarms(this);
	new CheckBackgroundUpdatesRunning(this, this.executorStatus).executeOnExecutor(this.localEs);
}