我一直在追查一个问题,我的代码块刚刚停止工作。最后,我确定了这条线,如下所示:
Log.v(TAG,"Here");
tv.setText("");
Log.v(TAG,"There");
在阻塞期间,第一个语句被调用,第二个语句不被调用。知道是什么原因造成的吗?
如果有任何疑问,tv 是一个 TextView。没有打印出任何错误,事实上,这条线以前曾经工作过......
最佳答案
我想出了我的问题所在,我将答案发布在这里以帮助将来的任何人。它可能是一个 Android 错误,或者是一些奇怪的东西......没有错误被发布。底线是,不要在 ScheduledThreadPoolExecutor
中进行 GUI 调用。
ScheduledThreadPoolExecutor masterExecutor;
masterExecutor=new ScheduledThreadPoolExecutor(1);
masterExecutor.schedule(new Runnable(){
@Override
public void run() {
//Formerly, I ran the block of code here, that blocked.
runOnUiThread ( new Runnable()
{
@Override
public void run() {
//Now I moved the code inside of a runOnUiThread
}
});
}
},1000,TimeUnit.MILLISECONDS);
关于android - 如果有的话,什么情况会导致 TextView.setText ("") 阻塞?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13551055/