over 9 years ago
Hi Friends, TextClock is used to show the current time or/and date. In TextClock we use formatted String to show the time or/and date. Basically it is a digital clock added from Api level 17 replacement of DigitalClock. By using this method we get values either getFormat12Hour() or getFormat24Hour().
Is24HourModeEnabled()
Here is the code
- Button showTextClock = (Button) findViewById(R.id. button);
- showTextClock.setOnClickListener(new OnClickListener() {
- @Override public void onClick(View v) {
- // TODO Auto-generated method stub
- // Defining Text Clock
- TextClock textClock = (AnalogClock) findViewById(R.id. my_text_clock);
- // Showing Text clock
- textclock.setVisibility(View.VISIBLE);
- } });
- } }
Button showTextClock = (Button) findViewById(R.id. button); showTextClock.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub // Defining Text Clock TextClock textClock = (AnalogClock) findViewById(R.id. my_text_clock); // Showing Text clock textclock.setVisibility(View.VISIBLE); } }); } }
This is the xml file of the Activity
- <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools"
- android:layout_width="match_parent"
- android:layout_height="match_parent">
- <textclockclock android:id="@+id/my_text_clock"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:visibility="invisible">
- <button android:id="@+id/ button"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Show Text Clock">
- </button>
- </textclockclock>
- </linearlayout>
<linearlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent"> <textclockclock android:id="@+id/my_text_clock" android:layout_width="wrap_content" android:layout_height="wrap_content" android:visibility="invisible"> <button android:id="@+id/ button" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Show Text Clock"> </button> </textclockclock> </linearlayout>
Can you help out the community by solving one of the following Version Control problems?
Do activity (Answer, Blog) > Earn Rep Points > Improve Rank > Get more opportunities to work and get paid!
For more topics, questions and answers, please visit the Tech Q&A page.
0 Comment(s)