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
中进行设置。因此,您必须同时使用 format12Hour
和 format24Hour
属性,以确保在这两种情况下,格式均为 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/