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

The following are Jave code examples for showing how to use setDisplayShowTitleEnabled() of the android.support.v7.app.ActionBar class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: GitHub   File: BaseActivity.java   Source Code and License Vote up 7 votes
/**
 * 设置titlebar
 */
protected void setToolBar() {
    setSupportActionBar(mBaseBinding.toolBar);
    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        //去除默认Title显示
        actionBar.setDisplayShowTitleEnabled(false);
        actionBar.setDisplayHomeAsUpEnabled(true);
        actionBar.setHomeAsUpIndicator(R.drawable.icon_back);
    }
    mBaseBinding.toolBar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            onBackPressed();
        }
    });
}
 
Example 2
Project: qvod   File: BaseTitleActivity.java   Source Code and License Vote up 6 votes
@Override
public void setContentView(int layoutResID) {
    super.setContentView(R.layout.activity_top);
    //
    llTitleMenu = $(R.id.ll_title_menu);
    llTitleMenu.setOnClickListener(this);
    toolbar = $(R.id.toolbar);
    svContent = $(R.id.sv_content);
    getLayoutInflater().inflate(layoutResID, svContent);
    //ActionBar
    setSupportActionBar(toolbar);
    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        //去除默认Title显示
        actionBar.setDisplayShowTitleEnabled(false);
    }
    //
    StatusBarUtil.setColor(this,ContextCompat.getColor(this, R.color.colorTheme));
}
 
Example 3
Project: easynote   File: SettingsActivity.java   Source Code and License Vote up 6 votes
private void initView() {
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    View sortOrder = findViewById(R.id.sort_order);
    View chooseDefaultImage = findViewById(R.id.choose_default_image);
    View secretNotePassword = findViewById(R.id.secret_note_password);
    View about = findViewById(R.id.about);

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

    sortOrder.setOnClickListener(this);
    chooseDefaultImage.setOnClickListener(this);
    secretNotePassword.setOnClickListener(this);
    about.setOnClickListener(this);
}
 
Example 4
Project: AndroidOCRFforID   File: UCropActivity.java   Source Code and License Vote up 6 votes
/**
 * Configures and styles both status bar and toolbar.
 */
private void setupAppBar() {
    setStatusBarColor(mStatusBarColor);

    final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);

    // Set all of the Toolbar coloring
    toolbar.setBackgroundColor(mToolbarColor);
    toolbar.setTitleTextColor(mToolbarWidgetColor);

    /*final TextView toolbarTitle = (TextView) toolbar.findViewById(R.id.toolbar_title);
    toolbarTitle.setTextColor(mToolbarWidgetColor);
    toolbarTitle.setText(mToolbarTitle);*/

    // Color buttons inside the Toolbar
    Drawable stateButtonDrawable = ContextCompat.getDrawable(this, R.drawable.ucrop_ic_cross).mutate();
    stateButtonDrawable.setColorFilter(mToolbarWidgetColor, PorterDuff.Mode.SRC_ATOP);
    toolbar.setNavigationIcon(stateButtonDrawable);

    setSupportActionBar(toolbar);
    final ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setDisplayShowTitleEnabled(false);
    }
}
 
Example 5
Project: GitHub   File: SlideShadeViewActivity.java   Source Code and License Vote up 6 votes
private void setTitleBar() {
    setSupportActionBar(binding.titleToolBar);
    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        //去除默认Title显示
        actionBar.setDisplayShowTitleEnabled(false);
        actionBar.setDisplayHomeAsUpEnabled(true);
        actionBar.setHomeAsUpIndicator(R.drawable.icon_back);
    }

    // title
    binding.tvTitle.setText(subjectsBean.getTitle());
    // 副标题
    binding.tvSubtitle.setText("主演:" + StringFormatUtil.formatName(subjectsBean.getCasts()));

    binding.titleToolBar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            onBackPressed();
        }
    });
}
 
Example 6
Project: Quran   File: PagerActivity.java   Source Code and License Vote up 5 votes
private void updateActionBarTitle(int page) {
  String sura = QuranInfo.getSuraNameFromPage(this, page, true);
  ActionBar actionBar = getSupportActionBar();
  if (actionBar != null) {
    translationsSpinner.setVisibility(View.GONE);
    actionBar.setDisplayShowTitleEnabled(true);
    actionBar.setTitle(sura);
    String desc = QuranInfo.getPageSubtitle(this, page);
    actionBar.setSubtitle(desc);
  }
}
 
Example 7
Project: ClouldReader   File: BaseHeaderActivity.java   Source Code and License Vote up 5 votes
/**
 * 设置toolbar
 */
protected void setToolBar() {
    setSupportActionBar(bindingTitleView.tbBaseTitle);
    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        //去除默认Title显示
        actionBar.setDisplayShowTitleEnabled(false);
        actionBar.setDisplayHomeAsUpEnabled(true);
        actionBar.setHomeAsUpIndicator(R.drawable.icon_back);
    }
    // 手动设置才有效果
    bindingTitleView.tbBaseTitle.setTitleTextAppearance(this, R.style.ToolBar_Title);
    bindingTitleView.tbBaseTitle.setSubtitleTextAppearance(this, R.style.Toolbar_SubTitle);
    bindingTitleView.tbBaseTitle.inflateMenu(R.menu.base_header_menu);
    bindingTitleView.tbBaseTitle.setOverflowIcon(ContextCompat.getDrawable(this, R.drawable.actionbar_more));
    bindingTitleView.tbBaseTitle.setNavigationOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            onBackPressed();
        }
    });
    bindingTitleView.tbBaseTitle.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem item) {
            switch (item.getItemId()) {
                case R.id.actionbar_more:// 更多信息
                    setTitleClickMore();
                    break;
            }
            return false;
        }
    });
}
 
Example 8
Project: Hello-Music-droid   File: ArtistDetailFragment.java   Source Code and License Vote up 5 votes
private void setupToolbar() {

        ((AppCompatActivity) getActivity()).setSupportActionBar(toolbar);

        final ActionBar ab = ((AppCompatActivity) getActivity()).getSupportActionBar();
        ab.setDisplayShowTitleEnabled(false);
        ab.setDisplayHomeAsUpEnabled(true);
    }
 
Example 9
Project: AndroidModulePattern   File: BaseActivity.java   Source Code and License Vote up 5 votes
/**
 * Setup the toolbar.
 *
 * @param toolbar   toolbar
 * @param hideTitle 是否隐藏Title
 */
protected void setupToolBar(Toolbar toolbar, boolean hideTitle) {
    setSupportActionBar(toolbar);
    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setHomeAsUpIndicator(R.drawable.ic_arrow_back);
        actionBar.setDisplayHomeAsUpEnabled(true);
        actionBar.setDisplayShowHomeEnabled(true);
        if (hideTitle) {
            //隐藏Title
            actionBar.setDisplayShowTitleEnabled(false);
        }
    }
}
 
Example 10
Project: item-reaper   File: ItemsActivity.java   Source Code and License Vote up 5 votes
@Override
public void onDialogDismissed() {
    mDialogOpen = false;
    setSupportActionBar(mToolbar);
    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setDisplayShowTitleEnabled(false);
    }
    onCreateOptionsMenu(mToolbar.getMenu());
}
 
Example 11
Project: Quran   File: PagerActivity.java   Source Code and License Vote up 5 votes
private void updateActionBarSpinner() {
  if (translationItems == null || translationItems.length == 0) {
    int page = getCurrentPage();
    updateActionBarTitle(page);
    return;
  }

  if (translationsSpinnerAdapter == null) {
    translationsSpinnerAdapter = new TranslationsSpinnerAdapter(this,
        R.layout.translation_ab_spinner_item, translationItems, translations,
        quranSettings.getActiveTranslations(),
        translationItemChangedListener) {
      @NonNull
      @Override
      public View getView(int position, View convertView, @NonNull ViewGroup parent) {
        convertView = super.getView(position, convertView, parent);
        SpinnerHolder holder = (SpinnerHolder) convertView.getTag();
        int page = getCurrentPage();

        String sura = QuranInfo.getSuraNameFromPage(PagerActivity.this, page, true);
        holder.title.setText(sura);
        String desc = QuranInfo.getPageSubtitle(PagerActivity.this, page);
        holder.subtitle.setText(desc);
        holder.subtitle.setVisibility(View.VISIBLE);
        return convertView;
      }
    };
    translationsSpinner.setAdapter(translationsSpinnerAdapter);
  }

  ActionBar actionBar = getSupportActionBar();
  if (actionBar != null) {
    actionBar.setDisplayShowTitleEnabled(false);
    translationsSpinner.setVisibility(View.VISIBLE);
  }
}
 
Example 12
Project: item-reaper   File: AuthActivity.java   Source Code and License Vote up 5 votes
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_auth);
    ButterKnife.bind(this);
    setSupportActionBar(mToolbar);
    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setDisplayShowTitleEnabled(false);
    }
    Typeface appbarTitle = Typeface.createFromAsset(getAssets(), "Nosifer-Regular.ttf");
    mAppbarTitle.setTypeface(appbarTitle);

    // Create the View
    AuthFragment authFragment = (AuthFragment) getSupportFragmentManager()
            .findFragmentById(R.id.contentFrame);
    if (authFragment == null) {
        authFragment = AuthFragment.newInstance();
        initFragment(authFragment);
    }

    // Create the Presenter which does the following:
    // Sets authFragment as the View for authPresenter.
    // Sets authPresenter as the presenter for authFragment.
    AuthComponent authComponent = DaggerAuthComponent.builder()
            .authModule(new AuthModule(authFragment))
            .applicationComponent(((ItemReaperApplication)getApplication()).getApplicationComponent())
            .build();
    authComponent.getAuthPresenter();
}
 
Example 13
Project: Blockly   File: AbstractBlocklyActivity.java   Source Code and License Vote up 5 votes
/**
 * Restores the {@link ActionBar} contents when the navigation window closes, per <a
 * href="http://developer.android.com/design/material/index.html">Material design
 * guidelines</a>.
 */
protected void restoreActionBar() {
    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setDisplayShowTitleEnabled(true);
        actionBar.setTitle(getWorkspaceTitle());
    }
}
 
Example 14
Project: Nird2   File: BriarActivity.java   Source Code and License Vote up 5 votes
/**
 * 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;
}
 
Example 15
Project: FormMaster   File: FormListenerActivity.java   Source Code and License Vote up 5 votes
private void setupToolBar() {

        final ActionBar actionBar = getSupportActionBar();

        if (actionBar != null) {
            actionBar.setDisplayShowTitleEnabled(false);
            actionBar.setDisplayHomeAsUpEnabled(true);
            actionBar.setHomeButtonEnabled(true);
        }

    }
 
Example 16
Project: Matisse-Image-and-Video-Selector   File: MatisseActivity.java   Source Code and License Vote up 4 votes
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    // programmatically set theme before super.onCreate()
    mSpec = SelectionSpec.getInstance();
    setTheme(mSpec.themeId);
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_matisse);

    if (mSpec.needOrientationRestriction()) {
        setRequestedOrientation(mSpec.orientation);
    }

    if (mSpec.capture) {
        mMediaStoreCompat = new MediaStoreCompat(this);
        if (mSpec.captureStrategy == null)
            throw new RuntimeException("Don't forget to set CaptureStrategy.");
        mMediaStoreCompat.setCaptureStrategy(mSpec.captureStrategy);
    }

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    ActionBar actionBar = getSupportActionBar();
    actionBar.setDisplayShowTitleEnabled(false);
    actionBar.setDisplayHomeAsUpEnabled(true);
    Drawable navigationIcon = toolbar.getNavigationIcon();
    TypedArray ta = getTheme().obtainStyledAttributes(new int[]{R.attr.album_element_color});
    int color = ta.getColor(0, 0);
    ta.recycle();
    navigationIcon.setColorFilter(color, PorterDuff.Mode.SRC_IN);

    mButtonPreview = (TextView) findViewById(R.id.button_preview);
    mButtonApply = (TextView) findViewById(R.id.button_apply);
    mButtonPreview.setOnClickListener(this);
    mButtonApply.setOnClickListener(this);
    mContainer = findViewById(R.id.container);
    mEmptyView = findViewById(R.id.empty_view);

    mSelectedCollection.onCreate(savedInstanceState);
    updateBottomToolbar();

    mAlbumsAdapter = new AlbumsAdapter(this, null, false);
    mAlbumsSpinner = new AlbumsSpinner(this);
    mAlbumsSpinner.setOnItemSelectedListener(this);
    mAlbumsSpinner.setSelectedTextView((TextView) findViewById(R.id.selected_album));
    mAlbumsSpinner.setPopupAnchorView(findViewById(R.id.toolbar));
    mAlbumsSpinner.setAdapter(mAlbumsAdapter);
    mAlbumCollection.onCreate(this, this);
    mAlbumCollection.onRestoreInstanceState(savedInstanceState);
    mAlbumCollection.loadAlbums();
}
 
Example 17
Project: rebase-android   File: ToolbarActivity.java   Source Code and License Vote up 4 votes
public void setDisplayShowTitleEnabled(boolean enabled) {
    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setDisplayShowTitleEnabled(enabled);
    }
}
 
Example 18
Project: Matisse   File: MatisseActivity.java   Source Code and License Vote up 4 votes
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    // programmatically set theme before super.onCreate()
    mSpec = SelectionSpec.getInstance();
    setTheme(mSpec.themeId);
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_matisse);

    if (mSpec.needOrientationRestriction()) {
        setRequestedOrientation(mSpec.orientation);
    }

    if (mSpec.capture) {
        mMediaStoreCompat = new MediaStoreCompat(this);
        if (mSpec.captureStrategy == null)
            throw new RuntimeException("Don't forget to set CaptureStrategy.");
        mMediaStoreCompat.setCaptureStrategy(mSpec.captureStrategy);
    }

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    ActionBar actionBar = getSupportActionBar();
    actionBar.setDisplayShowTitleEnabled(false);
    actionBar.setDisplayHomeAsUpEnabled(true);
    Drawable navigationIcon = toolbar.getNavigationIcon();
    TypedArray ta = getTheme().obtainStyledAttributes(new int[]{R.attr.album_element_color});
    int color = ta.getColor(0, 0);
    ta.recycle();
    navigationIcon.setColorFilter(color, PorterDuff.Mode.SRC_IN);

    mButtonPreview = (TextView) findViewById(R.id.button_preview);
    mButtonApply = (TextView) findViewById(R.id.button_apply);
    mButtonPreview.setOnClickListener(this);
    mButtonApply.setOnClickListener(this);
    mContainer = findViewById(R.id.container);
    mEmptyView = findViewById(R.id.empty_view);

    mSelectedCollection.onCreate(savedInstanceState);
    updateBottomToolbar();

    mAlbumsAdapter = new AlbumsAdapter(this, null, false);
    mAlbumsSpinner = new AlbumsSpinner(this);
    mAlbumsSpinner.setOnItemSelectedListener(this);
    mAlbumsSpinner.setSelectedTextView((TextView) findViewById(R.id.selected_album));
    mAlbumsSpinner.setPopupAnchorView(findViewById(R.id.toolbar));
    mAlbumsSpinner.setAdapter(mAlbumsAdapter);
    mAlbumCollection.onCreate(this, this);
    mAlbumCollection.onRestoreInstanceState(savedInstanceState);
    mAlbumCollection.loadAlbums();
}
 
Example 19
Project: IdealMedia   File: NavigationDrawerFragment.java   Source Code and License Vote up 4 votes
/**
 * 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.setTitle(R.string.app_name);
}
 
Example 20
Project: MovieApp   File: MovieListFragment.java   Source Code and License Vote up 4 votes
private void init(View view) {
    ButterKnife.bind(this, view);

    activity = (AppCompatActivity) getActivity();
    activity.setSupportActionBar(toolbar);
    ActionBar actionBar = activity.getSupportActionBar();
    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);
        actionBar.setDisplayShowTitleEnabled(true);
        actionBar.setTitle(fragmentTitle);
    }

    recyclerView.setHasFixedSize(true);
    recyclerView.setMotionEventSplittingEnabled(false);
    recyclerView.setItemAnimator(new DefaultItemAnimator());
    recyclerView.setAdapter(movieListAdapter);
    recyclerView.setLayoutManager(setUpLayoutManager());
    recyclerView.setItemAnimator(new DefaultItemAnimator());
    recyclerView.addOnScrollListener(setupScrollListener(recyclerView.getLayoutManager()));

    tryAgainBtn.setOnClickListener(v -> {
        switch (ID) {
            case 1:
                if (movieListAdapter.isEmpty()) {
                    movieListPresenter.mostPopularListRequested();
                }
                break;
            case 2:
                if (movieListAdapter.isEmpty()) {
                    movieListPresenter.onTopRatedMoviesRequested();
                }
                break;
            case 3:
                if (movieListAdapter.isEmpty()) {
                    movieListPresenter.onBoxOfficeRequested();
                }
                break;
            case 4:
                if(movieListAdapter.isEmpty()) {
                    movieListPresenter.onPopularMovieByGenreRequested(genreId);
                }
                break;
        }
    });

}