如何获取和设置 textView 文本 (Xamarin.Android)

How to get and set a textView text (Xamarin.Android)

我必须编写一个代码,从 textView 获取文本并将文本附加到它。 但是,不幸的是,我的代码不起作用。它实际上什么都不做 这是我所做的:

private void btnClicked(object sender, System.EventArgs e)
    {

        txtViewOne.Text += "0";

    }

在 android 中,您可以这样做而不使用任何内置函数

 txtViewOne.setText(txtViewOne.getText()+"0");

或将附加值存储到任何字符串

String appendedString=txtViewOne.getText()+"0";

在 c# 中相同

txtViewOne.Text=txtViewOne.Text+"0";

and do not use the += operator. it will not work on Strings. it is an arithmetic operator

你可以像下面这样写就可以了

private void btnClicked(object sender, System.EventArgs e)
        {

            txtViewOne.Text =txtViewOne.Text + "0";

        }

有内置解决方案,试试TextView.Append()

developer.xamarin.com -> api -> Android.Widget.TextView.Append(System.String)