【问题标题】:Set textview xamarin not working设置 textview xamarin 不工作
【发布时间】:2016-11-18 21:47:45
【问题描述】:

我尝试从后面的代码中更改文本。这是我的代码

TextView txtHome1 = FindViewById<TextView>(Resource.Id.txtHome);
txtHome1.Text = "Hello";
SetContentView(Resource.Layout.Home);

当我点击按钮时,它会移动到 Home 布局,txtHome 处于 Home 布局,我尝试设置 txtHome = "Hello" 但不能,请帮助我!

【问题讨论】:

    标签: xamarin visual-studio-2015 xamarin.android


    【解决方案1】:

    您的代码顺序错误。 先设置内容视图,然后编辑文本。

    SetContentView(Resource.Layout.Home);
    TextView txtHome1 = FindViewById<TextView>(Resource.Id.txtHome);
    txtHome1.Text = "Hello";
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-06-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-04-24
      相关资源
      最近更新 更多