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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T01:53:24+00:00 2026-06-12T01:53:24+00:00

Just to be clear, this question is not about how to update a TextView

  • 0

Just to be clear, this question is not about how to update a TextView from a Thread, that’s working fine. The problem is that even if I make multiple calls to update the TextView throughout the Thread, the updates only appear after the Thread is done it’s work. Here’s an example:

public class NDThread extends Thread {

    protected LogActionListener log_listener;
    private Handler handler = new Handler();


    public void run() {
        logAction("starting");
        // Do many things..
        logAction("halfway");
        // Many more things..
        logAction("done");
    }

    public interface LogActionListener {
        public void onLogAction(String paramString);
    }

    public void logAction(final String str) {
        if(log_listener != null) handler.post(new Runnable() {
            @Override
            public void run() {
                log_listener.onLogAction(str);          
            }       
        });
    }
}

And in my main Activity, I implement LogActionListener to recieve the Strings and update the TextView:

NDThread thread = new NDThread();
thread.setOnLogActionListener(this);
thread.run();

// Elsewhere..
@Override
public void onLogAction(final String msg) {
        handler.post(new Runnable() {

            @Override
            public void run() {
                textView.append(msg);
            }

        });
}

As you can see, I’ve used Handlers in both the Thread and the Activity because I wasn’t really sure which was correct to use. However, the result is always a blank TextView for the entirety of the Thread, then at the end it will print the 3 lines. What am I doing wrong?

  • 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-12T01:53:26+00:00Added an answer on June 12, 2026 at 1:53 am

    Avoid Thread and Go For AsyncTask

    What you are looking for is onProgressUpdate(Progress…) , publishProgress(Progress…) of AsyncTask

    Google for their code samples.

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

Sidebar

Related Questions

EDIT: Just to make things clear, this problem was caused by a typo in
I am asking this question primarily because I do not have some ideas clear.
Did my best to not post this question but i just can not figure
Just to make this clear, I have looked at the other questions on this
The javascript one seems pretty simple, just localStorage.clear(). Is there anything similar to that
Just to be clear, I am not asking for legal advice, I am asking
UPDATE: Just to be clear, I'd like to check the key-value of the 'name'
I'm reading Metaprogramming Ruby and just want to clear something up about the following
Just a (hopefully) quick question to clear something up with how Javascript handles objects.
I have to edit my question just to make it clear. What I need

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.