什么情况(如果有的话)会导致 TextView.setText( " " ) 阻塞?



我一直在追踪一个问题,即我的代码块停止工作。最后,我确定了这条线,如下所示:

Log.v(TAG,"Here");
tv.setText("");
Log.v(TAG,"There");

在阻塞期间,第一个语句被调用,第二个语句不被调用。知道是什么原因造成的吗?

如果有任何疑问,电视是文本视图。打印出来没有错误,事实上,这条线以前曾经工作过......

我想出了我的问题是什么,我在这里发布答案是为了将来帮助任何人。这可能是一个安卓错误,或者一些奇怪的东西......从未发布过任何错误。底线是,不要在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);

相关内容

最新更新