2016-03-01 133 views
0

所以我想要完成的是一個計時器,我在visual studio中使用xamarin,它的目標是爲android.I在xaml中有一個名爲txtStopwatch的TextView,我想開始計算第二個第一個按鈕被點擊。這個計時器和結束按鈕被隱藏,直到擊中按鈕。計時器,按鈕點擊開始

 if (btnStart.Click == true) 

     { 

      btnStart.Visibility = ViewStates.Gone; 
      btnEnd.Visibility = ViewStates.Visible; 
      Stopwatch.Start() = txtStopwatch.Text; 
     } 

     else 

     { 

      btnStart.Visibility = ViewStates.Visible; 
      btnEnd.Visibility = ViewStates.Gone; 
      Stopwatch.Start(); 

     } 

回答

0

假設秒錶是秒錶的一個實例(非常可怕的命名,千萬不要用一個實例類的類型名稱):

if (btnStart.Click == true) 
    { 

     btnStart.Visibility = ViewStates.Gone; 
     btnEnd.Visibility = ViewStates.Visible; 
     Stopwatch.Start(); 
    } 
    else 
    { 

     btnStart.Visibility = ViewStates.Visible; 
     btnEnd.Visibility = ViewStates.Gone; 
     Stopwatch.Stop(); 
     txtStopwatch.Text = Stopwatch.Elapsed.ToString(); 
    }