【问题标题】:Android Chronometer: set format of chronometer [closed]Android Chronometer:设置计时器的格式[关闭]
【发布时间】:2013-03-18 13:06:42
【问题描述】:

我有一个计时器格式 (hh:mm:ss)。我喜欢有一个格式(mm:ss)(仅限分钟)。

例如:01:30:00 到 90:00。请帮帮我

【问题讨论】:

  • 我没有使用 setFormat()。只是计时器的默认格式

标签: android android-widget


【解决方案1】:

考虑这段代码:

/**
 * Format of the time
 */
private final static String MINUTE_SECOND_FORMAT = "%02d:%02d";

///// code... 

final int minutes = (currentSeconds % 3600) / 60;
final int seconds = currentSeconds % 60;

String formatted = String.format(Locale.getDefault(), MINUTE_SECOND_FORMAT, minutes, seconds);

这样你就可以得到一个格式化的字符串,格式为分:秒。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-08-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-08-02
    • 1970-01-01
    相关资源
    最近更新 更多