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

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);

关于android - 什么情况(如果有)会导致TextView.setText(“”)阻塞?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/13551055/

10-11 22:51
查看更多