Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7842267
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T16:16:53+00:00 2026-06-02T16:16:53+00:00

I´m trying to create a fullscreen clock. I managed to set text for hours,

  • 0

I´m trying to create a fullscreen clock. I managed to set text for hours, minutes and seconds. Well, but when I start the app, it shows the time but the UI is not updating… I dont know how to do it, I read this tutorial but i dont understand it… any one can explain me how to consantly update the UI?

 public class Clock1Activity extends Activity {
/** Called when the activity is first created. */
private Timer timer;
@Override
public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.main);

final TextView txtHour = (TextView)findViewById(R.id.TxtHour);
final TextView txtMinutes = (TextView)findViewById(R.id.TxtMinute);
final TextView txtSeconds = (TextView)findViewById(R.id.TxtSeconds);
final TextView txtMilliseconds = (TextView)findViewById(R.id.TxtMilliseconds);

 final Integer hora = new Integer(Calendar.HOUR_OF_DAY);
 final Integer minutos = new Integer(Calendar.MINUTE);
 final Integer segundos = new Integer(Calendar.SECOND);
 final Long milisegundos = new Long (System.currentTimeMillis());
    timer = new Timer("DigitalClock");
    Calendar calendar = Calendar.getInstance();
    // Get the Current Time
    final Runnable updateTask = new Runnable() {
        public void run() {
/** txtHour.setText(hora.toString());
 txtMinutes.setText(minutos.toString());
 txtSeconds.setText(segundos.toString()); */
 txtMilliseconds.setText(milisegundos.toString());
 Toast toast1 = Toast.makeText(getApplicationContext(), milisegundos.toString(), Toast.LENGTH_SHORT);
toast1.show();
        }
    };

    timer.scheduleAtFixedRate(new TimerTask() {
        @Override
        public void run() {
            runOnUiThread(updateTask);
        }
    }, 1, 1000);

}

}

Just tell me how to complete it to update UI,please…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T16:16:55+00:00Added an answer on June 2, 2026 at 4:16 pm

    see this example for Create a Apps to Show Digital Time in Android .And in your case use

    runOnUiThread for Upadting time on UI.as

    CurrentActivity.this.runOnUiThread(new Runnable() {
        public void run() {
            //UPDATE TIME HERE
        }
    });
    

    and your code look like:

    public class Clock1Activity extends Activity {
    /** Called when the activity is first created. */
    private Timer timer;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    
        final TextView txtHour = (TextView)findViewById(R.id.TxtHour);
        final TextView txtMinutes = (TextView)findViewById(R.id.TxtMinute);
        final TextView txtSeconds = (TextView)findViewById(R.id.TxtSeconds);
        final TextView txtMilliseconds = (TextView)findViewById(R.id.TxtMilliseconds);
    
    
            timer = new Timer("DigitalClock");
            Calendar calendar = Calendar.getInstance();
            // Get the Current Time
            final Runnable updateTask = new Runnable() {
                public void run() {
         final Integer hora = new Integer(Calendar.HOUR_OF_DAY);
         final Integer minutos = new Integer(Calendar.MINUTE);
         final Integer segundos = new Integer(Calendar.SECOND);
         final Integer milisegundos = new Integer(Calendar.MILLISECOND);
         txtHour.setText(hora.toString());
         txtMinutes.setText(minutos.toString());
         txtSeconds.setText(segundos.toString());
         txtMilliseconds.setText(milisegundos.toString());
                }
            };
    
            timer.scheduleAtFixedRate(new TimerTask() {
                @Override
                public void run() {
                    runOnUiThread(updateTask);
                }
            }, 1, 1000);
     }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Trying to create a PhoneGap app using the canvas tag on an iPad. The
I am trying to create a fullscreen chat program using Flash AS3, and so
to all im newbie developer and trying to create my first iPhone app, sorry
Well... I am trying to create an application using the TTS Engine. I can
I'm trying to create a mobile friendly website but I can't seem to get
I'm trying to create a simple app that draws rectangles within the Canvas tag.
I am trying create a new css for shaping my detailsview. But i couldn't
I'm trying create a text area in a div with the id of "body".
I'm trying to put a DIV block to fullscreen and create a "go back"
I am trying to scroll text across the screen which is working well. Update

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.