Advertisement
Guest User

Untitled

a guest
Oct 1st, 2016
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. public TextView txtTimer;
  2. public int count = 5;
  3. Timer t = new Timer();
  4.  
  5.  
  6. protected override void OnCreate(Bundle savedInstanceState)
  7. {
  8. base.OnCreate(savedInstanceState);
  9. SetContentView(Resource.Layout.Test);
  10.  
  11. txtTimer = FindViewById<TextView>(Resource.Id.textTimer);
  12. Timer t = new Timer();
  13. t.Interval = 1000;
  14. t.Elapsed +=T_Elapsed ;
  15.  
  16. t.Start();
  17.  
  18.  
  19.  
  20.  
  21.  
  22.  
  23. }
  24.  
  25. private void T_Elapsed(object sender, ElapsedEventArgs e)
  26. {
  27. if (count < 0)
  28. {
  29.  
  30.  
  31.  
  32. t.Stop();
  33.  
  34. //after the 5 seconds ends..i want to stop the timer and start a new activity which is called 'Result' to do another process
  35. Intent n = new Intent(this, typeof(Result));
  36. StartActivity(n);
  37.  
  38.  
  39. }
  40. else
  41. {
  42. RunOnUiThread(delegate {
  43.  
  44. //display the count down on screen
  45. txtTimer.Text = count.ToString();
  46. count--;
  47.  
  48.  
  49.  
  50. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement