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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T10:47:01+00:00 2026-06-13T10:47:01+00:00

Hi stackoverflow community, I’m using Android API 14 on a droid 4.0.3 device. In

  • 0

Hi stackoverflow community,

I’m using Android API 14 on a droid 4.0.3 device.

In the Activity I’ve set a Button to display a TextView on the page while it is performing an action. After the action is performed, I want the TextView to disappear again.

button1.setOnClickListener(new OnClickListener(){
    @Override
    public void onClick(View v) {
        // make textview visible 
        textView1.setVisibility(View.VISIBLE);      

        // perform action
        System.out.println("perform action");

        // make textview disappear
        textView1.setVisibility(View.GONE);
    }
});

If I remove the part that makes the TextView disappear, the TextView appears at the top of the window as expected, but I want the TextView to appear for 1-2 seconds and then disappear.

At first I wondered if I needed to do more work than just performing a small action, so I tried adding a wait and printing out text, but none of that worked. The wait always called the exception, ending the activity, and when I printed out numbers 1-1000 the view was still permanently gone.

Is there a better way to make a TextView appear and disappear on an OnClick action?

Thanks for your help!

  • 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-13T10:47:02+00:00Added an answer on June 13, 2026 at 10:47 am

    Those commands are executed back-to-back. So in a technical sense, it may be visible but only for a millisecond or two. You need to distinguish when to make the view visible and when to hide it…


    You said that you would like the TextView to “blink” in a sense, so let’s use the Handler that is a part of every View to call a Runnable. This Runnable will simply hide the TextView a few moments later:

    1) Set up a class variable:

    Runnable hide = new Runnable() {
        @Override
        public void run() {
            textView1.setVisibility(View.GONE);
        }
    };
    

    2) Call the runnable in a few moments:

    button1.setOnClickListener(new OnClickListener(){
        @Override
        public void onClick(View v) {
            // make textview visible for 1 second (1000 milliseconds)
            textView1.setVisibility(View.VISIBLE);      
            textView1.postDelayed(hide, 1000);
        }
    });
    

    (A Handler and Runnable does not block the UI thread.)

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

Sidebar

Related Questions

Hello StackOverflow community, Using Google App Engine, I wrote a keyToSha256() method within a
Dear members of the Stackoverflow community, We are developing a web application using the
I want to say hello to the stackoverflow community. I've just started using knockout
Hi stackoverflow community, i'm using RKObjectManager to make iOS RESTful requests to map responses
Hello stackoverflow community, I'm working on a puzzle game using Cocos2D/Box2D were the player
Hello Stackoverflow community, for a little game I need to display an octagon (
Greetings stackoverflow community! I am working on an Android game that uses Box2D for
Hi StackOverflow community, in my application I'd like to have a button which allows
Dear Stackoverflow community, I am a little bit confused using the VFPOleDb Library (9.0Sp2)
I am using perforce. Some helpful members of the stackoverflow community helped me find

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.