androidx.appcompat.widget.Toolbar.setTitle()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(5.9k)|赞(0)|评价(0)|浏览(243)

本文整理了Java中androidx.appcompat.widget.Toolbar.setTitle()方法的一些代码示例,展示了Toolbar.setTitle()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Toolbar.setTitle()方法的具体详情如下:
包路径:androidx.appcompat.widget.Toolbar
类名称:Toolbar
方法名:setTitle

Toolbar.setTitle介绍

暂无

代码示例

代码示例来源:origin: chrisbanes/PhotoView

@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_launcher);
  Toolbar toolbar = findViewById(R.id.toolbar);
  toolbar.setTitle(R.string.app_name);
  RecyclerView recyclerView = findViewById(R.id.list);
  recyclerView.setLayoutManager(new LinearLayoutManager(this));
  recyclerView.setAdapter(new ItemAdapter());
}

代码示例来源:origin: AppIntro/AppIntro

tb.setTitle(getResources().getString(R.string.app_name));
tb.setTitleTextColor(Color.parseColor("#FFFFFF"));

代码示例来源:origin: mikepenz/MaterialDrawer

@Override
  public boolean onItemClick(View view, int position, IDrawerItem drawerItem) {
    if (drawerItem != null && drawerItem.getIdentifier() == 1) {
      startSupportActionMode(new ActionBarCallBack());
      findViewById(R.id.action_mode_bar).setBackgroundColor(UIUtils.getThemeColorFromAttrOrRes(CompactHeaderDrawerActivity.this, R.attr.colorPrimary, R.color.material_drawer_primary));
    }
    if (drawerItem instanceof Nameable) {
      toolbar.setTitle(((Nameable) drawerItem).getName().getText(CompactHeaderDrawerActivity.this));
    }
    return false;
  }
})

代码示例来源:origin: ankidroid/Anki-Android

private void switchToState(int newState) {
  switch (newState) {
    case STATE_LOGGED_IN:
      String username = AnkiDroidApp.getSharedPrefs(getBaseContext()).getString("username", "");
      mUsernameLoggedIn.setText(username);
      mToolbar = mLoggedIntoMyAccountView.findViewById(R.id.toolbar);
      if (mToolbar!= null) {
        mToolbar.setTitle(getString(R.string.sync_account));  // This can be cleaned up if all three main layouts are guaranteed to share the same toolbar object
        setSupportActionBar(mToolbar);
      }
      setContentView(mLoggedIntoMyAccountView);
      break;
    case STATE_LOG_IN:
      mToolbar = mLoginToMyAccountView.findViewById(R.id.toolbar);
      if (mToolbar!= null) {
        mToolbar.setTitle(getString(R.string.sync_account));  // This can be cleaned up if all three main layouts are guaranteed to share the same toolbar object
        setSupportActionBar(mToolbar);
      }
      setContentView(mLoginToMyAccountView);
      break;
  }
  supportInvalidateOptionsMenu();  // Needed?
}

代码示例来源:origin: ankidroid/Anki-Android

private void adjustToolbar(View tagsDialogView) {
  Toolbar mToolbar = tagsDialogView.findViewById(R.id.tags_dialog_toolbar);
  mToolbar.setTitle(mDialogTitle);

代码示例来源:origin: iTXTech/Daedalus

@Override
  public void checkStatus() {
    menu.findItem(R.id.nav_settings).setChecked(true);
    toolbar.setTitle(R.string.action_settings);
  }
}

代码示例来源:origin: iTXTech/Daedalus

@Override
public void checkStatus() {
  menu.findItem(R.id.nav_dns_server).setChecked(true);
  toolbar.setTitle(R.string.action_dns_servers);
}

代码示例来源:origin: iTXTech/Daedalus

@Override
public void checkStatus() {
  menu.findItem(R.id.nav_dns_test).setChecked(true);
  toolbar.setTitle(R.string.action_dns_test);
}

代码示例来源:origin: iTXTech/Daedalus

@Override
public void checkStatus() {
  menu.findItem(R.id.nav_about).setChecked(true);
  toolbar.setTitle(R.string.action_about);
}

代码示例来源:origin: ZieIony/Carbon

private void initLayout() {
  inflate(getContext(), R.layout.carbon_toolbar, this);
  super.setNavigationIcon(null);
  super.setTitle(null);
  content = findViewById(R.id.carbon_toolbarContent);
  title = findViewById(R.id.carbon_toolbarTitle);
  icon = findViewById(R.id.carbon_toolbarIcon);
  icon.setOnClickListener(view -> {
    if (getContext() == null)
      return;
    Context context = getContext();
    while (!(context instanceof Activity))
      context = ((ContextWrapper) context).getBaseContext();
    if (context instanceof UpAwareActivity) {
      ((UpAwareActivity) context).onUpPressed();
    } else {
      ((Activity) context).onBackPressed();
    }
  });
}

代码示例来源:origin: chrisbanes/PhotoView

toolbar.setTitle("Simple Sample");
toolbar.setNavigationIcon(R.drawable.ic_arrow_back_white_24dp);
toolbar.setNavigationOnClickListener(new View.OnClickListener() {

代码示例来源:origin: iTXTech/Daedalus

@Override
public void checkStatus() {
  menu.findItem(R.id.nav_home).setChecked(true);
  toolbar.setTitle(R.string.action_home);
  updateUserInterface();
}

代码示例来源:origin: iTXTech/Daedalus

@Override
public void checkStatus() {
  menu.findItem(R.id.nav_log).setChecked(true);
  toolbar.setTitle(R.string.action_log);
  toolbar.inflateMenu(R.menu.log);
  toolbar.setOnMenuItemClickListener(this);
}

代码示例来源:origin: iTXTech/Daedalus

@Override
public void onPostCreate(Bundle savedInstanceState) {
  super.onPostCreate(savedInstanceState);
  Toolbar toolbar = findViewById(R.id.toolbar_config);
  switch (getIntent().getIntExtra(LAUNCH_ACTION_FRAGMENT, LAUNCH_FRAGMENT_DNS_SERVER)) {
    case LAUNCH_FRAGMENT_DNS_SERVER:
      toolbar.setTitle(R.string.config_dns_server);
      break;
    case LAUNCH_FRAGMENT_RULE:
      toolbar.setTitle(R.string.config_rule);
      break;
    default://should never reach this
      break;
  }
}

代码示例来源:origin: iTXTech/Daedalus

@Override
public void checkStatus() {
  menu.findItem(R.id.nav_rules).setChecked(true);
  toolbar.inflateMenu(R.menu.rules);
  toolbar.setTitle(R.string.action_rules);
  toolbar.setOnMenuItemClickListener(this);
  toolbar.getMenu().findItem(R.id.action_change_type).setTitle(Rule.getTypeById(currentType));
}

代码示例来源:origin: michael-rapp/ChromeLikeTabSwitcher

/**
 * Adapts the title of the toolbar, which is shown, when the tab switcher is shown.
 */
private void adaptToolbarTitle() {
  Toolbar[] toolbars = getToolbars();
  if (toolbars != null) {
    CharSequence title = style.getToolbarTitle();
    toolbars[TabSwitcher.PRIMARY_TOOLBAR_INDEX].setTitle(title);
  }
}

代码示例来源:origin: proninyaroslav/libretorrent

public void setTitle(String title)
{
  if (toolbar != null)
    toolbar.setTitle(title);
}

代码示例来源:origin: westnordost/StreetComplete

toolbar.setTitle("");
setSupportActionBar(toolbar);

代码示例来源:origin: andstatus/andstatus

public void setTitle(@StringRes int resId) {
  if (toolbar != null) {
    toolbar.setTitle(resId);
  }
}

代码示例来源:origin: InflationX/ViewPump

@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_main);
  final Toolbar toolbar = findViewById(R.id.toolbar);
  setSupportActionBar(toolbar);
  toolbar.setTitle(R.string.app_name);
}

相关文章