Very simple problem (probably)

by Tom3030 » Tue, 04 May 2010 03:06:31 GMT

Sponsored Links
 Hi All,

This is probably going to be extremely simplistic, but I have an
activity that does some work and is supposed to update the text view
to let the user know where the process is at (some sort of progress
indicator basically). But for some reason none of my textview updates
make it to the screen until the activity has basically completed, by
which time updates are pointless!

After the oncreate of the Activity class I have this ...

TextView tv = new TextView(this);

and then throughout the class at various points (at the moment just
one long procedure .... yeah I know ...) I have ...


etc. etc. but none of these appear while it's executing. I've tried
setting invalidate() but that doesn't seem to make it redraw. The
actual procedure itself runs fine (takes about 10-15 seconds). Do I
have to do some fancy threading to update the UI or what?



Very simple problem (probably)

by TreKing » Tue, 04 May 2010 03:17:44 GMT


Basically? Yup.

The gist of it is this: setText does just that - sets the text to be used on
the view - it doesn't actually do any drawing. That happens later on in the
main thread, after your onCreate call, so you can call setText as many times
as you want within a function, nothing but the last call will actually show
up during the next draw phase.

You will have to split out your loading code into a thread and post updates
to the main UI thread with the current progress. Or better yet, use an
AsyncTask - this is pretty much what it's for.

TreKing - Chicago transit tracking app for Android-powered devices 


Sponsored Links

Other Threads

1. RE : Droid 2.1-update1 EGL10.eglCreateWindowSurface() deadlocks intermittently

I didn't know about helixlauncher2. It's cool!

Now I can navigate the home screen just with the thumb. That never worked
reliable for me with the stock homescreen of the N1.

And everything is smooth. Feels like an iphone...

2010/4/7 seb boyart <>


2. How to prevent virtual keyboard from moving and resizing views

Is there a way to prevent the virtual keyboard from moving and
resizing views? I have a table with a row of 4 buttons at the bottom
of a relative layout that are centered and equally sized, very similar
to the 3 buttons that appear at the bottom of the Gmail app when an
email is checked.  When the virtual keyboard appears, the buttons move
to stay just above the virtual keyboard.  When this happens, the four
buttons become small and get squished to the left, leaving tons of
blank space to the right of the buttons. Is there a property I can set
on the table, row, and/or buttons to prevent this from happening?



3. Why launch is canceled

4. RE : Droid 2.1-update1 EGL10.eglCreateWindowSurface() deadlocks intermittently

5. java.lang.VerifyError and custom library sdk addon

6. Droid 2.1-update1 EGL10.eglCreateWindowSurface() deadlocks intermittently

7. Error message while running an application on adb shell