I used this code for adding a clock to my app:
<DigitalClock
android:id="@+id/digitalclock"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:textSize = "30sp"
/>
The problem is that it shows also seconds..there is a simple and fast way for hide those? I need just hours and minutes in hh:mm format instead of hh:mm:ss! any suggestions? Thanks!
The DigitalClock Javadoc states:
Judging by the
FIXME
, the ability to hide portions of DigitalClock might be implemented eventually. I didn't find anything currently in the Javadoc or source code that would do what you want it to.Unless you want to write your own class that extends DigitalClock (or your own clock implementation altogether), you could just cover the seconds portion of the DigitalClock with another element if it would serve your purpose.
Found the answer here, for anyone else looking for a working answer, here it is:
DigitalClock.java
from android sourceChange format strings within new
CustomDigitalClock
Reference custom class within in layout xml
Load CustomDigitalClock within activity/fragment