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

  • Home
  • SEARCH
  • 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 7409341
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T06:04:11+00:00 2026-05-29T06:04:11+00:00

I am trying to implement a simple digital clock with second and two colons

  • 0

I am trying to implement a simple digital clock with second and two colons changing every second. I have thought about using DigitalClock but I want the colons to flash as well as the second and don’t want to show am/pm. So I read the “Updating the UI from a Timer” and it suggests us to use Handler. So i use Handler and can change second and colons every second but the weird thing is that sometimes, it jumps a second (1,2,4,5,6). It seems the clock is a bit lagging. Is there any way to solve this problem? Thanks!

tick_handler = new Handler();
    Runnable updateSecond = new Runnable(){
        @Override
        public void run() {
            second.setText(DataModel.getSeconds());
            if(colon1.getVisibility()== View.VISIBLE){
                colon1.setVisibility(View.INVISIBLE);
                colon2.setVisibility(View.INVISIBLE);
            } else {
                colon1.setVisibility(View.VISIBLE);
                colon2.setVisibility(View.VISIBLE);
            }
            tick_handler.postDelayed(this, 1000);
        }
    };
tick_handler.postDelayed(updateSecond, 0);
  • 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-05-29T06:04:11+00:00Added an answer on May 29, 2026 at 6:04 am

    I suspect that you see this on the emulator as it is much slower than actual phones. Try changing the tick_handler.postDelayed(this, 1000); to a smaller value than 1 second, for e.g. 500 ms

    tick_handler.postDelayed(this, 500); 
    

    and add a global variable to track the differece between each time the thread runs and if the difference is 1 second, update the Views.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to implement a simple decimation algorithm in c++. I have two
I am trying to implement a simple request to Wikipedia's API using AJAX (XMLHttpRequest).
I am now trying to implement a simple HTML webpage scraper using Java.Now I
I've been trying to implement a simple component-based game object architecture using Objective-C, much
I'm new to Flex SDK and trying to implement a simple project using Doug
I'm still learning about Objective-C memory management. I'm trying to implement several simple classes
im trying to implement simple secured client server communiction using WCF. when im launching
I am trying to implement a simple Observer pattern using .net Observable class. I
I'm trying to implement simple sliding window alogirithm on two-dimensional array in C# 3.0,
I am trying to implement simple chat application using flex. In it all my

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.