TextView setText不刷新文本

时间:2017-01-15 17:15:46

标签: android multithreading android-fragments textview

Fragment我有Thread这个必须刷新文本的TextView setText()。问题是在TextView.getText()之后(事实上如果我记录了Fragment,它返回了更改的文本),屏幕文本总是相同的。只有在Thread time = new Thread() { public void run() { getActivity().runOnUiThread(new Runnable() { @Override public void run() { while(true) { TextView.setText("some text"); // i tried also to use TextView.invalidate() } }); } }; } 的视图中添加视图时,它才会更改。

这是代码,

$a = "x";
$$a = 'Value of $$a'; // creates a variable called $x
                      // because the literal value of $a = 'x'
                      // think about it as: ${$a}

echo $$a . "<br>";  // 'Value of $$a'
echo $x . "<br>";   // 'Value of $$a'

unset($a);

echo $a . "<br>";   // Notice: Undefined variable
echo $$a . "<br>";  // Notice: Undefined variable - because {$a} has been unset
echo $x . "<br>";   // 'Value of $$a' - $x has not been unset

1 个答案:

答案 0 :(得分:2)

删除while(true),用

阻止UI线程