Re: [android-developers] Re: update TextView inside a TimerTask

2012-03-14 Thread surya phani
thanks for ur code

On Tue, Mar 13, 2012 at 7:29 PM, harsh chandel harshdchan...@gmail.comwrote:

 you can use this timer given in devloper guide

  new CountDownTimer(3, 1000) {

public void onTick(long millisUntilFinished) {

TextView txttimer=(TextView)
 findViewById(R.id.timeremaining);
txttimer.setText(Time remaining: 0: +
 millisUntilFinished /
 1000);
}

public void onFinish() {


}
}.start();

 On Mar 13, 1:54 pm, Alimooghashang alimooghash...@gmail.com wrote:
  thank you very much
  now my application works well
 
  On Tue, Mar 13, 2012 at 11:21 AM, tsukishiro yamazaki 
 
 
 
 
 
 
 
  tsukishir...@gmail.com wrote:
   You can take the sample here
  
 http://developer.android.com/guide/topics/ui/dialogs.html#ProgressDialog
   for your reference.
   Check the sample code marked by the section  *Example ProgressDialog
   with a second thread*
 http://developer.android.com/guide/topics/ui/dialogs.html#

 
   Thanks and best regards,
   - tsukishiro
 
   On Tuesday, March 13, 2012 1:20:18 PM UTC+9, Ali wrote:
 
   Hi
   i have made a timer and a timer task, and i need to update my textview
   every seconds
   how can i do that?
   thanks
 
--
   You received this message because you are subscribed to the Google
   Groups Android Developers group.
   To post to this group, send email to
 android-developers@googlegroups.com
   To unsubscribe from this group, send email to
   android-developers+unsubscr...@googlegroups.com
   For more options, visit this group at
  http://groups.google.com/group/android-developers?hl=en

 --
 You received this message because you are subscribed to the Google
 Groups Android Developers group.
 To post to this group, send email to android-developers@googlegroups.com
 To unsubscribe from this group, send email to
 android-developers+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/android-developers?hl=en




-- 
PHANI SURYA

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Re: [android-developers] Re: update TextView inside a TimerTask

2012-03-13 Thread Alimooghashang
Hi
thanks
i wonder if you help me with an example!
i implemented timer like this:

Timer t = new Timer();

 TimerTask tt = new TimerTask() {
  @Override
  public void run() {
  }
  };
 t.scheduleAtFixedRate(tt, 100, 1000);


my texview is this:

 TextView tv = (TextView)findViewById(R.id.TextView06);
 tv.setText( String.valueOf(myval));


On Tue, Mar 13, 2012 at 9:03 AM, tsukishiro yamazaki tsukishir...@gmail.com
 wrote:

 If I'm not mistaken, any code inside a TimerTask is running on a different
 thread. This means that it won't have access to the main UI thread. So if
 you put some code in there to update your Textview, you will probably end
 up with an exception or error saying that it cannot access the main ui
 thread. To fix this, you will need to create a message handler (Handler) so
 that you can send messages to your main ui thread telling it to update
 the Textview accordingly.


 On Tuesday, March 13, 2012 1:20:18 PM UTC+9, Ali wrote:

 Hi
 i have made a timer and a timer task, and i need to update my textview
 every seconds
 how can i do that?
 thanks

  --
 You received this message because you are subscribed to the Google
 Groups Android Developers group.
 To post to this group, send email to android-developers@googlegroups.com
 To unsubscribe from this group, send email to
 android-developers+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/android-developers?hl=en


-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

[android-developers] Re: update TextView inside a TimerTask

2012-03-13 Thread tsukishiro yamazaki
You can take the sample here   
http://developer.android.com/guide/topics/ui/dialogs.html#ProgressDialog   
for your reference.
Check the sample code marked by the section  *Example ProgressDialog with 
a second thread*http://developer.android.com/guide/topics/ui/dialogs.html#
 

Thanks and best regards,
- tsukishiro


On Tuesday, March 13, 2012 1:20:18 PM UTC+9, Ali wrote:

 Hi
 i have made a timer and a timer task, and i need to update my textview 
 every seconds
 how can i do that?
 thanks


-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Re: [android-developers] Re: update TextView inside a TimerTask

2012-03-13 Thread Alimooghashang
thank you very much
now my application works well



On Tue, Mar 13, 2012 at 11:21 AM, tsukishiro yamazaki 
tsukishir...@gmail.com wrote:

 You can take the sample here
 http://developer.android.com/guide/topics/ui/dialogs.html#ProgressDialog
 for your reference.
 Check the sample code marked by the section  *Example ProgressDialog
 with a second 
 thread*http://developer.android.com/guide/topics/ui/dialogs.html#
  

 Thanks and best regards,
 - tsukishiro


 On Tuesday, March 13, 2012 1:20:18 PM UTC+9, Ali wrote:

 Hi
 i have made a timer and a timer task, and i need to update my textview
 every seconds
 how can i do that?
 thanks

  --
 You received this message because you are subscribed to the Google
 Groups Android Developers group.
 To post to this group, send email to android-developers@googlegroups.com
 To unsubscribe from this group, send email to
 android-developers+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/android-developers?hl=en


-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

[android-developers] Re: update TextView inside a TimerTask

2012-03-13 Thread harsh chandel
you can use this timer given in devloper guide

 new CountDownTimer(3, 1000) {

public void onTick(long millisUntilFinished) {

TextView txttimer=(TextView) 
findViewById(R.id.timeremaining);
txttimer.setText(Time remaining: 0: + 
millisUntilFinished /
1000);
}

public void onFinish() {


}
}.start();

On Mar 13, 1:54 pm, Alimooghashang alimooghash...@gmail.com wrote:
 thank you very much
 now my application works well

 On Tue, Mar 13, 2012 at 11:21 AM, tsukishiro yamazaki 







 tsukishir...@gmail.com wrote:
  You can take the sample here
 http://developer.android.com/guide/topics/ui/dialogs.html#ProgressDialog
  for your reference.
  Check the sample code marked by the section  *Example ProgressDialog
  with a second 
  thread*http://developer.android.com/guide/topics/ui/dialogs.html#
   

  Thanks and best regards,
  - tsukishiro

  On Tuesday, March 13, 2012 1:20:18 PM UTC+9, Ali wrote:

  Hi
  i have made a timer and a timer task, and i need to update my textview
  every seconds
  how can i do that?
  thanks

   --
  You received this message because you are subscribed to the Google
  Groups Android Developers group.
  To post to this group, send email to android-developers@googlegroups.com
  To unsubscribe from this group, send email to
  android-developers+unsubscr...@googlegroups.com
  For more options, visit this group at
 http://groups.google.com/group/android-developers?hl=en

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: update TextView inside a TimerTask

2012-03-12 Thread tsukishiro yamazaki
If I'm not mistaken, any code inside a TimerTask is running on a different 
thread. This means that it won't have access to the main UI thread. So if 
you put some code in there to update your Textview, you will probably end 
up with an exception or error saying that it cannot access the main ui 
thread. To fix this, you will need to create a message handler (Handler) so 
that you can send messages to your main ui thread telling it to update 
the Textview accordingly.

On Tuesday, March 13, 2012 1:20:18 PM UTC+9, Ali wrote:

 Hi
 i have made a timer and a timer task, and i need to update my textview 
 every seconds
 how can i do that?
 thanks


-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en