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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T20:53:52+00:00 2026-05-18T20:53:52+00:00

The example is pretty straightforward: i want to let the user know about what

  • 0

The example is pretty straightforward: i want to let the user know about what the app is doing by just showing a text (canvas.drawText()). Then, my first message appears, but not the other ones. I mean, i have a “setText” method but it doesn’t updates.

onCreate(Bundle bundle) {
    super.onCreate(bundle);
    setContentView(splash); // splash is the view class
    loadResources();
    splash.setText("this");
    boundWebService();
    splash.setText("that"):
    etc();
    splash.setText("so on");
}

The view’s text drawing works by doing just a drawText in onDraw();, so setText changes the text but doesn’t show it.

Someone recommended me replacing the view with a SurfaceView, but it would be alot of trouble for just a couple of updates, SO… how the heck can i update the view dinamically at runtime?

It should be quite simple, just showing a text for say 2 seconds and then the main thread doing his stuff and then updating the text…

Thanks!

Update:

I tried implementing handler.onPost(), but is the same story all over again. Let me put you the code:

public class ThreadViewTestActivity extends Activity {

Thread t;
Splash splash;

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

    splash = new Splash(this);
    t = new Thread(splash);
    t.start();

    splash.setTextow("OA");
    try { Thread.sleep(4000); } catch (InterruptedException e) { }
    splash.setTextow("LALA");
}       
}

And:

public class Splash implements Runnable {

Activity activity;
final Handler myHandler = new Handler();

public Splash(Activity activity) {
    this.activity=activity;
}   

@Override
public void run() {
    // TODO Auto-generated method stub

}

public synchronized void setTextow(final String textow) {
    // Wrap DownloadTask into another Runnable to track the statistics
    myHandler.post(new Runnable() {
        @Override
        public void run() {
            TextView t = (TextView)activity.findViewById(R.id.testo);
            t.setText(textow);
            t.invalidate(); 
        }                   
    });
}
}

Although splash is in other thread, i put a sleep on the main thread, i use the handler to manage UI and everything, it doesn’t changes a thing, it only shows the last update.

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

    I haven’t hit this yet, but I think the usual pattern is to do lengthy initialization in a background thread, and use Handler.post() to update the UI. See http://developer.android.com/reference/android/widget/ProgressBar.html for a different, but possibly related, example.

    Also see this answer, especially the first paragraph:

    The problem is most likely that you
    are running the splash screen (some
    sort of Dialog such as ProgressDialog
    I assume) in the same thread as all
    the work being done. This will keep
    the view of the splash screen from
    being updated, which can keep it from
    even getting displayed to the screen.
    You need to display the splash screen,
    kick off an instance of AsyncTask to
    go download all your data, then hide
    the splash screen once the task is
    complete.

    Update (based on your update and your comment): You are not supposed to update the UI in any thread except the one where your Activity is created. Why is it impossible for you to load your resources in a background thread?

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

Sidebar

Related Questions

Adding buttons showing standard Outlook icons to a Ribbon is pretty straightforward. Set the
A pretty silly trivial question. The canonical example is f = open('filename') , but
My question is pretty vague :o) - But here is an example : When
I'm pretty new to XQuery and I'm trying to write an example function that
I'm attempting a pretty cut & dry example of anydbm: #!/usr/bin/python import anydbm #
CGI.escapeHTML is pretty bad, but CGI.unescapeHTML is completely borked. For example: require 'cgi' CGI.unescapeHTML('…')
I'm modifying existing security code. The specifications are pretty clear, there is example code,
Example I have Person , SpecialPerson , and User . Person and SpecialPerson are
I have legacy win.forms application written in pretty straightforward approach where forms communicate with
Don't be frightened by the length of the post, it should be pretty straightforward.

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.