从数字时钟部件卸下秒和AM / PM [英] Remove seconds and AM/PM from Digital clock widget

查看:254
本文介绍了从数字时钟部件卸下秒和AM / PM的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想删除秒,从数字时钟部件AM / PM指示,但我不知道如何做到这一点。

I want to remove the seconds and AM/PM indication from the digital clock widget but I don't know how to do this.

推荐答案

这是在DigitalClock类硬codeD,所以你不能编程改变它。改变它的唯一方法是重新实现DigitalClock部件。哟,可以从源头code <一个href=\"http://grep$c$c.com/file/repository.grep$c$c.com/java/ext/com.google.android/android/1.5_r4/android/widget/DigitalClock.java\">here.

It is hard-coded in the DigitalClock class, so you can't change it programatically. The only way to change it is to re-implement DigitalClock widget. Yo can get source code from here.

您需要在您的项目复制此code,像MyDigitalClock重命名,并使用这一个作为你的小部件。正如你将在实施看,有两个变量,你应该专注于得到你想要什么:

You need to copy this code in your project, rename it like "MyDigitalClock" and use this one as your widget. As you will see in the implementation, there are two variables you should focus on to get what you want:

private final static String m12 = "h:mm:ss aa";
private final static String m24 = "k:mm:ss";

SS再presents秒和AA重新presents AM / PM。

ss represents seconds and aa represents am/pm.

这篇关于从数字时钟部件卸下秒和AM / PM的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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