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);
tv.setText("Starting.");
setContentView(tv);

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

tv.setText("Working...");

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?

Cheers,
Tom.

--



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
 http://sites.google.com/site/rezmobileapps/treking 

--


Sponsored Links


Other Threads

1. i want to place native source files except under /jni

is it possible?

Actually, i make shared library without ndk-build.
I just use make command on cygwin with ndk-r4b. it work good!

But i got a some problem(unsatisfied link error) when i try to use
multiple shared library - I think, it't must be my mistake :-). I
don't know what's the problem.

Anyway, nowdays i try to use ndk-build.(because, it's google's
recommend).
I guess, if i success using ndk-build, multiple shared library will be
work.

But, i have a meet another problem. It is native source file's
position.(it looks like... native source place must be
under JNI folder, i don't want).

So, can i place the native source files other position?

-- 

2. delete an SMS in Android before it reaches the inbox

hi guys,

According to the
http://stackoverflow.com/questions/1741628/can-we-delete-an-sms-in-android-before-it-reaches-the-inbox/2566199#2566199
it is possible to delete a SMS before it reaches inbox by setting
android:priority attribute on the listener and calling
abortBroadcast() to stop propagating it to other apps.

is this feature still working in Android 2.2? I tried this on the
emulator and i can see the top notification bar shows the new message
upon arrival. I tried calling

BroadcastReceiver

@Override
        public void onReceive(Context context, Intent intent) {
                abortBroadcast();
                setResultData(null);
        }


AndroidManifest.xml

<receiver android:name=".SMSReceiver" android:enabled="true"
android:priority = "100" >
              <intent-filter>
                <action
android:name="android.provider.Telephony.SMS_RECEIVED" />
              </intent-filter>
</receiver>


still no luck. How can i make it work? please advice

Thank a lot
-Walpappa

-- 

3. C2DM Server with PHP 401 Error

4. lg ally phone not connecting to blocks editor

5. Programatically end an Intent - Specifically the RecognizerIntent

6. What is iconLevel on notification?

7. Is there any way to get foreground activity's window preference?