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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T20:33:15+00:00 2026-05-25T20:33:15+00:00

I’m trying to develop a feature for my app that pulls a string of

  • 0

I’m trying to develop a feature for my app that pulls a string of text off of the internet (sort of like twitter, but a lot more basic) and displays it on the screen in a permeanent window. The user sees a large box with a refresh button next to it, and a small space below both where I would like to have a little progress monitor (just a TextView) which displays “Refreshing…” as soon as the refresh button is clicked, and then “Refresh successful!” once the string of text has been successfully pulled from the internet and displayed. This is just to reassure the user that something is actually happening when they press the button.

After a lot of research I’ve come to the conclusion that the way to update the TextView is to use a handler to execute a runnable which will update the text in the TextView. So my code looks like this:

    refreshbutton.setOnClickListener(new View.OnClickListener()
    {
        public void onClick(View abc)
        {
                //display "Refreshing..."
                refreshhandler.post(refreshingmsg);

            /*Code to pull the string of text from the internet goes here (not shown)*/

                //display "Refresh successul!"
                successfulhandler.post(successfulmsg);

                //clear the "Refresh successful" message after 2 seconds
                clearhandler.postDelayed(clearmsg, 2000);
            }
    });

I hope that sort of makes sense. My issue is that these things all happen at once: I want the “Refreshing…” message to display, THEN for the phone to connect to the internet to find the string of text for the update, and THEN for the “Refresh Successful” message to display once the internet string has been successfully displayed. But what actually happens is that none of the commands in the onClick method actually happen until the phone has already pulled the message from the internet so the “Refreshing…” message isn’t displayed at all. So what actually happens when the user clicks the button is that nothing happens for a second or two (presumably because the phone is busy pulling the string from the internet), then the string from the internet is suddenly displayed along with the message saying “Refresh Successful!”.

So why is this happening? Is onClick supposed to work this way? If so, is there a workaround? I haven’t posted my runnable and handler statements because I’m not sure it’ll make any difference… but if it would help then I can post them!

Also, you can probably tell from this that I haven’t been doing android (or indeed java) for very long, but I’m trying my best so please be gentle! Thanks 🙂

  • 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-25T20:33:15+00:00Added an answer on May 25, 2026 at 8:33 pm

    What is happening is that your code is locking on the network communication and doesn’t let your app update itself with the handler value.

    You should create an AsyncTask to that work for you.

    On the OnPreExecute method, change your UI to show the user that you are refreshing your content. Reading your code it appears that you are updating an image, do that here.

    On the doInBackground method do your actual network communication, an optional step is to use onProgressUpdate(Progress...) to update your UI to notify the user that the operation is progressing.

    On the onPostExecute method you them update your UI to reflect the new content.

    For more info check the documentation in AsyncTask, you can also search StackOverflow, there’s a lot of good questions about it here.

    As a side note, I don’t recommend that you use handlers at all, AsyncTasks are easier to use and the code looks better.

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

Sidebar

Related Questions

For some reason, after submitting a string like this Jack’s Spindle from a text
I've got a string that has curly quotes in it. I'd like to replace
I want to count how many characters a certain string has in PHP, but
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I'm trying to create an if statement in PHP that prevents a single post
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i

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.