1

Okay I have a text view that changed every time a user types in an answer or response. I dont want the computers response to appear automatically but maybe pause for 3 to 5 seconds with a prograss dialog, or something to show its processing data, when its really not. What would i implement in my code to do this. Any help would be great. Thanks

theITRanger22
  • 184
  • 6
  • 19

3 Answers3

1

for this I would create a timer that will disable the text view after they have finished doing what they want and then enable it again after x number of seconds. You could even create the timer with a random length of time between 3 and 5 seconds so it seems random.

http://developer.android.com/reference/java/util/Timer.html

Hope this helps.

stuartmclark
  • 1,203
  • 13
  • 22
  • Thanks sounds like what i need! – theITRanger22 Jun 20 '11 at 15:18
  • To help you guys better understand what im trying to do. Here is an example public void onCreate(){ – theITRanger22 Jun 20 '11 at 15:18
  • To help you guys better understand what im trying to do. Here is an example public void onCreate(){ setContentView(r.layout.main) textView.setText("Welcome enter your name"); // The user enters there name in the EditText box respond.setOnClickListener(new View.OnClickListener){ //Once the user enters there name i would like it to pause and display a progress dialog before the next textView. I hope this makes more since what im trying to do. Thanks for Everyone help! } } – theITRanger22 Jun 20 '11 at 15:24
0

You could use an AsyncTask within which you would call Thread.sleep(Random.nextInt(2)+3) in the doInBackground() method. Within the AsyncTask class, you can show and hide the progress bar with the onPreExecute() and onPostExecute() methods.

Haphazard
  • 10,900
  • 6
  • 43
  • 55
0

Probably .. this solution Counting Chars in EditText Changed Listener invoking a thread for controlling progress dialog can solve your problem

Community
  • 1
  • 1
success_anil
  • 3,659
  • 3
  • 27
  • 31