我以编程方式创建了TextView,如何使用TextView来更改文本?
代码
protected override void OnCreate(Bundle bundle){
base.OnCreate(bundle);
var layout = new LinearLayout(this);
layout.Orientation = Orientation.Vertical;
var relativeLayout = new RelativeLayout(this);
layout.AddView(relativeLayout);
TextView textViewTime = new TextView(this);
textViewTime.Text = "00:00:00";
textViewTime.Id = 1;
relativeLayout.AddView(textViewTime);
...
}
public class MyScrollView : HorizontalScrollView
{
...
protected override void OnScrollChanged(int l, int t, int oldl, int oldt)
{
TextView tv = (TextView)FindViewById(1); //returns null
...
}
}