我是C#和Xamarin的新手,我可能會錯誤地介紹這個解決方案,但是我聲明的值將通過用戶輸入0-10數字獲得,而不是小數點後面沒有負數。這將做一個基本的數學運算a/b * c = answer ...然後我想顯示var C(答案)並最終使用它來改變一個計時器間隔。然而現在,我很難讓代碼顯示我的答案作爲文本供用戶查看....請參閱下面的代碼。Xamarin中的C#計算,顯示答案的問題。
[Activity(Label = "Infusion Calculator")]
public class infusionact : Activity
{
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
SetContentView(Resource.Layout.Infusion);
// Create your application here
var volume = FindViewById<EditText>(Resource.Id.boxvolume);
var drip = FindViewById<EditText>(Resource.Id.boxdrip);
var dripmins = FindViewById<EditText>(Resource.Id.boxmins);
var answermins = (Resource.Id.boxvolume/Resource.Id.boxmins * Resource.Id.boxdrip);
Button button = FindViewById<Button>(Resource.Id.btncalculate);
TextView textView1 = (TextView)FindViewById(Resource.Id.textView1);
button.Click += delegate
{
// NEED TO FIGURE OUT HOW TO SET TXT LABEL WITH VAR ANSWERMINS ON CLICK
textView1.SetText(answermins);
};
}
}