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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T21:42:46+00:00 2026-05-15T21:42:46+00:00

onCreate, MyActivity will display five TextViews. After you touch one of the five TextViews,

  • 0

onCreate, MyActivity will display five TextViews. After you touch one of the five TextViews, it will hide three to four TextViews and color one red and one green or just color one green.

I can code everything up to here. But how can I pause for a few seconds and then repopulate the five TextViews with new values, unhide them and make them all white?

Thanks in advance!

NEW EDIT NEW EDIT NEW EDIT

I tried a Timer in a new project and can attach the code and make my question less vague.

Here is the main.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
<TextView
    android:id="@+id/hello"  
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:text="@string/hello" />
</LinearLayout>

Here is the TestTimer.java

package com.somecompany.android.testtimer;

import java.util.Timer;
import java.util.TimerTask;

import android.app.Activity;
import android.graphics.Color;
import android.os.Bundle;
import android.util.Log;
import android.widget.TextView;

public class TestTimer extends Activity {
    TextView hello;

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    hello = (TextView)findViewById(R.id.hello);
    hello.setTextColor(Color.rgb(0,255,0));

    new Reminder(5);
    }

    void resetAndContinue() {
    Log.d("TESTTIMER", "Start resetAndContinue...");
    hello.setTextColor(Color.rgb(255,255,255));
    Log.d("TESTTIMER", "End  resetAndContinue...");
    }

    class Reminder {
    Timer timer;

    public Reminder(int seconds) {
        timer = new Timer();
        timer.schedule(new RemindTask(), seconds*1000);
    }

    class RemindTask extends TimerTask {
        public void run() {
        Log.d("TESTTIMER", "Ran TagRemindTask");
        resetAndContinue();
        timer.cancel(); //Terminate the timer thread
        }
    }


    }
}

The issue is that the Timer executes resetAndContinue and logs two entries, but it doesn’t set the TextView color from green to white and it doesn’t log anymore

07-15 13:08:46.894: DEBUG/TESTTIMER(618): Ran TagRemindTask

07-15 13:08:46.894: DEBUG/TESTTIMER(618): Start resetAndContinue…

07-15 13:08:47.264: DEBUG/dalvikvm(524): GC freed 202 objects / 8936 bytes in 156ms

07-15 13:08:52.224: DEBUG/dalvikvm(210): GC freed 43 objects / 2096 bytes in 85ms

  • 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-15T21:42:47+00:00Added an answer on May 15, 2026 at 9:42 pm

    Although your question is very general and vague, I’ll try to answer it:

    To “pause” your Activity, there are several possibilities. If it doesn’t have to react on user input, but just execute a specific method after a specific amount of time, I would recommend to use TimerTask in combination with Timer. For an explanation of how this works you can use this reference.

    To set new values to a TextView (assuming that new values means a new text to display), you should use the method TextView.setText(…). To hide/unhide a TextView, you could use the method setVisibility(…). To make a TextView white (assuming that you’re talking of the TextView background) you can use the method setBackgroundColor(…).

    I hope this will help you. If you have any questions, you have to provide us with code and more detailed questions.

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

Sidebar

Related Questions

Android will call onCreate() of my activity whenever it is launched. In the onCreate()
I am trying to develop a simple map application, which will display a map
Here I create one project that will track our current location. But I have
Will this kind of code cause memory leak in Android? class MyActivity extends Activity
Let's say I have MyActivity and inside my onCreate method I initialize MyBackgroundView, then
In the onCreate() of an activity, I've got a call to requestFocus() on an
I've noticed in some coding people use icicle with the onCreate method, and I
I have Activity with ListView inside it and in the onCreate method of the
I have a class derived from CTreeCtrl . In OnCreate() I replace the default
I have built my interface by using ViewStubs, which I inflate during onCreate. But

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.