java - 我如何仅从 textClock 获取小时

标签 java android xml textview

in this i am trying to get only hour from the textclock and show on my widget and it works perfectly on Android device and when test on BlackBerry it shows complete time like 12:50 PM instead of hour

              <TextClock
                android:id="@+id/tvHourWidget"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:fontFamily="sans-serif-black"
                android:format12Hour="hh"
                android:text="00"
                android:textColor="@color/colorPrimary"
                android:textSize="@dimen/basic_twice" />

here is the code i have tried

最佳答案

您无法设置设备是 12 小时制还是 24 小时制,也无法在 TextView 中进行设置。因此,您必须同时使用 format12Hourformat24Hour 属性,以确保在这两种情况下,格式均为 hh:

<TextClock
            android:id="@+id/tvHourWidget"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:fontFamily="sans-serif-black"
            android:format12Hour="hh"
            android:format24Hour="hh"
            android:text="00"
            android:textColor="@color/colorPrimary"
            android:textSize="@dimen/basic_twice" />

关于java - 我如何仅从 textClock 获取小时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62428637/

相关文章:

java - Android中WebView加载URL时如何显示进度条?

java - Android 与 iOS 中 View 的位置?

java - 无法加载 JDBC 驱动程序。为什么? ( Spring , hibernate )

java - 使用非常高的 CPU 和内存的 Elasticsearch Java

android - 更改 IP 地址以在真实设备上运行 MobileFirst Android 应用程序

java - 当我按下返回按钮时应用程序崩溃

java - 用于从 Java 生成 Word 文档的 xsl 样式表

java - ActiveMQ 并发问题 - 多个消费者使用队列中的同一消息

java - 用来自 RxJava 的可观察对象替换回调

java - 错误: java. lang.RuntimeException,如何正确从 Intent 中获取额外内容?