设置天文钟表的HH:MM:SS [英] Set HH:MM:SS of Chronometer

查看:211
本文介绍了设置天文钟表的HH:MM:SS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道天文钟的格式可以是MM:SS或HH:MM:SS,但是我想知道如何使用setFormat()和getFormat()来设置HH:MM:SS模式(现在是MM:SS) ).

I knew the format of chronometer can be MM:SS or HH:MM:SS, but I want to know how to use setFormat() and getFormat() to set HH:MM:SS pattern(now is MM:SS).

这时,我使用: android:format="@string/chronometer_initial_format"通过声明设置格式:

At this time, I use: android:format="@string/chronometer_initial_format" to set Format by declare:

<xliff:g id="initial-format">%1$s</xliff:g>

位于res/values/strings.xml

at res/values/strings.xml

我试图通过谷歌搜索来搜索,但没有很好的答案. 有人可以建议吗? 谢谢

I tried to search by googling, but can't get good answer. Anyone can suggest ? Thank you

推荐答案

来自

设置用于以下内容的格式字符串 展示.计时器将显示 此字符串,带有第一个%s" 替换为中的当前计时器值 "MM:SS"或"H:MM:SS"形式.如果 格式字符串为null,或者如果从不 调用setFormat(),计时器将 只需在以下位置显示计时器值 "MM:SS"或"H:MM:SS"表格.

Sets the format string used for display. The Chronometer will display this string, with the first "%s" replaced by the current timer value in "MM:SS" or "H:MM:SS" form. If the format string is null, or if you never call setFormat(), the Chronometer will simply display the timer value in "MM:SS" or "H:MM:SS" form.

H:MM:SS输出的显示取决于经过的时间:您不能明确选择显示小时.如果自启动以来已超过一个小时,则它将显示小时数,否则将仅显示分钟和秒.

The display of the H:MM:SS output depends on the elapsed time: you can not explicitly choose to display the hours. If it has been more than an hour since it started then it will display the hour number, otherwise it will only display the minutes and seconds.

此外,您的格式必须仅包含%s:我不认为您可以使用%1$s或其他索引格式说明符.

Also, your format must only have %s: I don't believe you can use %1$s or other indexed format specifiers.

这篇关于设置天文钟表的HH:MM:SS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆