LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 02-18-2012, 07:22 AM   #1
Larry James
Member
 
Registered: Jun 2000
Location: Buffalo, New York
Distribution: Ubuntu, Raspbian
Posts: 381

Rep: Reputation: 40
How to Pause/Delay execution in Android Application?


I'm trying to write code that will place a delay between steps without clearing the screen.

Code:
TextView infotext;
String inforstring;

for (int x = 1; x < 10; x++ ){
	infostring = infostring + "\n" + x;				
	infotext.setText(infostring);
	// 10 second delay here
	...
}
I tried using the Thread.sleep() function, but it clears the screen and doesn't give the display back until all the iterations have completed, then all the numbers are displayed.

Code:
try {
	Thread.sleep(10000);
} catch (InterruptedException e) {}
Thanks in advance for any suggestions or comments.

-- L. James

--
L. D. James
ljames@apollo3.com
www.apollo3.com/~ljames
 
Old 02-18-2012, 01:08 PM   #2
Larry James
Member
 
Registered: Jun 2000
Location: Buffalo, New York
Distribution: Ubuntu, Raspbian
Posts: 381

Original Poster
Rep: Reputation: 40
I left a line out of my previous post (for the benefit of anyone that might want to test the example. I'm reposting the code below.

I'm also including a for-next loop to set a delay. This presents the same problem as in my original post.

Code:
TextView infotext;
String infostring = "Counting:";

for (int x = 1; x < 10; x++ ){
	infostring = infostring + "\n" + x;
        //line left off previous post
	infotext = (TextView) findViewById(R.id.infotext);
	infotext.setText(infostring);

	// Delay loop between iterations
        // Do nothing loop... just count to a big number
	for (int y = 1; y < 10000000; y++){}
}
Thanks again for any comments on this!


-- L. James

--
L. D. James
ljames@apollo3.com
www.apollo3.com/~ljames
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
delay in thread execution..!! manohar Programming 5 11-26-2011 02:15 PM
making the parent direct child processes to pause/sleep and resume execution expeliarmus Programming 1 08-14-2007 05:11 AM
Pause Execution in VB ashirazi Programming 2 08-17-2005 06:17 PM
Setting a delay for rc.4 execution losingfight Linux - Newbie 5 04-27-2005 03:50 AM
sleep() looking for a way to pause execution for fractions of a second qwijibow Programming 3 02-20-2005 02:38 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:52 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration