将EditText中的数字添加到TextView

时间:2015-02-28 14:41:35

标签: c# android xamarin

如何从EditText添加数字,然后在TextView中显示它们?

我试图转换它们但它不起作用......

total = FindViewById<TextView> (Resource.Id.textView14);
input1 = FindViewById<EditText> (Resource.Id.editText1);
input2 = FindViewById<EditText> (Resource.Id.editText2);

TextView total;
EditText input1, input2;

int totalScore;
totalScore = Convert.ToInt32(input1) + Convert.ToInt32(input2);

        btnCalc.Click += (object sender, EventArgs e) => {
            total.Text = Convert.ToString(totalScore);
        };

感谢您的帮助..

1 个答案:

答案 0 :(得分:0)

    btnCalc.Click += (object sender, EventArgs e) => {
        totalScore = Convert.ToInt32(input1.Text) + Convert.ToInt32(input2.Text);
        total.Text = totalScore.ToString();
    };