在android中动态更改textview内容

在android中动态更改textview内容,text,time,textview,Text,Time,Textview,我有一个文本视图,其中设置了一个变量。此变量随时间而变化。我希望此文本视图的文本也会自动更改。我该怎么做?是否可以添加计时器之类的内容,并在其运行时更新文本?如果要在单击按钮时添加,请在OnClick()中使用此选项 LinearLayout child_layout = new LinearLayout(this); child_layout.setOrientation(LinearLayout.HORIZONTAL); TextView subject_name = new TextVie

我有一个文本视图,其中设置了一个变量。此变量随时间而变化。我希望此文本视图的文本也会自动更改。我该怎么做?是否可以添加计时器之类的内容,并在其运行时更新文本?

如果要在单击按钮时添加,请在OnClick()中使用此选项

LinearLayout child_layout = new LinearLayout(this);
child_layout.setOrientation(LinearLayout.HORIZONTAL);
TextView subject_name = new TextView(MainActivity.this);
textview.setText("add_new_text");
child_layout.addView(textview);

String text = "your_text";
textview.setText(text);