Go Back   Android Forums > Android Development > Application Development
Application Development Dev lounge for our application developers.

test: Reply
 
LinkBack Thread Tools
Old October 30th, 2010, 01:26 PM   #1 (permalink)
New Member
Thread Author (OP)
 
Join Date: Oct 2010
Posts: 1
 
Device(s):
Carrier: Not Provided

Thanks: 0
Thanked 0 Times in 0 Posts
Lightbulb Please help with Handler class to update UI

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 Updating the UI from a Timer | Android Developers and Common Tasks and How to Do Them in Android | Android Developers 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!

Advertisements
QueryMan is offline  
Reply With Quote
sponsored links
Reply
Tags
gui, handler, timer, update, user interface


Go Back   Android Forums > Android Development > Application Development
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 10:50 PM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.