Updating TextView In One Function
I want to do something very simple. I have a progress-bar and a textView
that I want to dynamically update on a button click, but more than once
during the function call.
I want it to change to 'A' then wait a second, then switch to 'B' ... for
example.
I understand that my function blocks the UI/main thread, which is what if
I setText() ten times, I only see the tenth text appear when the function
completes.
So I've tried handlers/runnables in the UI thread, invalidating (and
postInvalidating) to encourage refreshing and runOnUiThread() and they all
just update when they've finished running leaving me only with the final
state.
public void requestPoint(View v) {
textProgress.setText("Requesting A Point");
waiting(200);
progressBar.setProgress(5);
textProgress.setText("Request Received!");
waiting(500);
....
}
Where waiting() is a function I made that waits without actually affecting
the thread.
I think I've turned nearly all the similar question links purple and
wasted way too much time on this simple thing (although I did learn a lot
about threading on Android) but I feel I must be missing something
crucial, this doesn't seem like that hard of task.
Any help would be greatly appreciated.
No comments:
Post a Comment