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 8098437
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T22:04:45+00:00 2026-06-05T22:04:45+00:00

I am currently learning how to develop applications for Android mobile devices. I wrote

  • 0

I am currently learning how to develop applications for Android mobile devices.

I wrote a test application to display numbers 0-9 on the device screen. I created a simple function to delay the number change.

However, upon running the application, only the final number is displayed. There is also a delay before this final number shows. I’m assuming that the length of the pause is my defined delay multiplied by the number of digits to be shown.

How do I create an app that changes the numbers with a delay?

public class AndroidProjectActivity extends Activity {
    public void onCreate(Bundle savedInstanceState){
        super.onCreate(savedInstanceState);
        Main();
    }

void Delay(int Seconds){
    long Time = 0;
    Time = System.currentTimeMillis();
    while(System.currentTimeMillis() < Time+(Seconds*1000));
}

void Main() {
    String ConvertedInt;
    TextView tv = new TextView(this);
    setContentView(tv);

    for(int NewInt = 0; NewInt!= 9; NewInt++){
        ConvertedInt = Character.toString((char)(NewInt+48));
        tv.setText(ConvertedInt);
        Delay(5);
    }
}
  • 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-05T22:04:46+00:00Added an answer on June 5, 2026 at 10:04 pm

    One way of doing this is to create a runnable that updates your view. This will still update on the UI thread, but wait in the background. There might be mistakes in the below code, but it should run with minor tweaks..

    Blocking in any of the system calls into your activity is not good, since you’re blocking the UI thread. Your app will be force closed, with an Application Not Responding message. Here is another good example.

    public class AndroidProjectActivity extends Activity {
        private Handler mHandler;
        private TextView mTextView;
        private Runnable mCountUpdater = new Runnable() {
            private int mCount = 0;
            run() {
               if(mCount > 9)
                   return;
               mTextView.setText(String.valueOF(mCount+48));
               mCount++;
               // Reschedule ourselves.
               mHandler.postDelayed(this, 5000);
            }
        }
        public void onCreate(Bundle savedInstanceState){
            super.onCreate(savedInstanceState);
            // Cleaner to load a view from a layout..
            TextView tv = new TextView(this);
            setContentView(tv);
            mTextView = tv;
            // Create handler on UI thread.
            mHandler = new Handler();
            mHandler.post(mCountUpdater);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently learning to develop for Android and I'm having a somewhat hard time
I have recently just started learning how to develop android applications. I am am
I'm currently learning to develop for the .net compact framework using c# in VS2008
Hi I am currently learning how to use service and notifications in android and
I'm currently learning how to develop and building an app for windows phone 7.
I am currently learning ARM Assembly and I was wandering whether I could test
I would like to develop an android application with the following description: The app
I'm trying to develop a machine learning system for playing Super Mario. The application
im currently learning python (in the very begining), so I still have some doubts
im currently learning stacks in java and have a quick question. what will the

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.