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

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

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

Toolbar.setSubtitle介绍

暂无

代码示例

代码示例来源:origin: cbeyls/fosdem-companion-android

@Override
  public void onChanged(Map<String, RoomStatus> roomStatuses) {
    RoomStatus roomStatus = roomStatuses.get(roomName);
    if (roomStatus != null) {
      SpannableString roomNameSpannable = new SpannableString(context.getString(roomStatus.getNameResId()));
      int color = ContextCompat.getColor(context, roomStatus.getColorResId());
      roomNameSpannable.setSpan(new ForegroundColorSpan(color),
          0, roomNameSpannable.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
      toolbar.setSubtitle(roomNameSpannable);
    } else {
      toolbar.setSubtitle(null);
    }
  }
});

代码示例来源:origin: gotify/android

@SuppressWarnings("StatementWithEmptyBody")
@Override
public boolean onNavigationItemSelected(MenuItem item) {
  // Handle navigation view item clicks here.
  int id = item.getItemId();
  if (item.getGroupId() == R.id.apps) {
    selectAppIdOnDrawerClose = id;
    startLoading();
    toolbar.setSubtitle(item.getTitle());
  } else if (id == R.id.nav_all_messages) {
    selectAppIdOnDrawerClose = MessageState.ALL_MESSAGES;
    startLoading();
    toolbar.setSubtitle("");
  } else if (id == R.id.logout) {
    new AlertDialog.Builder(this)
        .setTitle(R.string.logout)
        .setMessage(getString(R.string.logout_confirm))
        .setPositiveButton(R.string.yes, this::doLogout)
        .setNegativeButton(R.string.cancel, (a, b) -> {})
        .show();
  } else if (id == R.id.nav_logs) {
    startActivity(new Intent(this, LogsActivity.class));
  }
  drawer.closeDrawer(GravityCompat.START);
  return true;
}

代码示例来源:origin: cbeyls/fosdem-companion-android

toolbar.setSubtitle(day.toString());
setTitle(String.format("%1$s, %2$s", track.toString(), day.toString()));
ThemeUtils.setStatusBarTrackColor(this, track.getType());

相关文章