Hi Everyone, I am hoping you can help me:
I need to update my ui for an android app and I'm trying to use the
Handler class to do it, using
http://developer.android.com/resources/articles/timed-ui-updates.html
and the android developer resources "Common Task" for using Handlers
as guides.
Basically, I need something between the two - a timed update of the
user interface, but without a button. So here is the relevent code
that I am working on. All help is greatly appreciated.
public class Activity1 extends Activity {
[… variables]
final Handler mHandler = new Handler();
final Runnable mUpdateResults = new Runnable() {
public void run() {
UpdateDisplay();
mHandler.postDelayed(mUpdateResults, 200);
}
};
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
[…]
startLongRunningOperation();
}
protected void startLongRunningOperation() {
Thread t = new Thread() {
public void run() {
if (mStartTime == 0L) {
mStartTime = System.currentTimeMillis();
mHandler.postDelayed(mUpdateResults, 200);}
mHandler.post(mUpdateResults);
}
};
t.start();
}
Thanks again!
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en