-1

i'm trying to set text of text view in a while loop as

 t = (TextView)findViewById(R.id.textView1);  
    while(true)  
    {  
     t.setText(hr+":"+":"min+":"+sec);  
      try{  
          Thread.sleep(1000);  
         }  
      catch(Exception e){}  
    }  

But while running the app text is not changing. when i removed the while loop then it was setting
text correctly.
why was so? Plz Help!!!!!!!!!strong text

Blackbelt
  • 156,034
  • 29
  • 297
  • 305
Dhruvam Gupta
  • 482
  • 5
  • 10

1 Answers1

1

you never change the values of hr, min and sec. Also you are calling Thread.sleep(1000); on the UI Thread, which is responsable to draw the text in your text view. Of course, it will be unable to do that while it is sleeping.

Blackbelt
  • 156,034
  • 29
  • 297
  • 305
  • i'm calling a method logic() as a first line in while loop in which i'm changing the values of hr,min,sec accordingly. but nevertheless it is not changing. when i remove only while loop and remaining body same then it works fine. Why is it so? – Dhruvam Gupta Nov 17 '14 at 04:13