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

标签 android textview

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

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/

相关文章:

android - 在 Google Cloud Messaging 的用户通知中创建 notification_key 时出现 404 错误

java - Pattern.compile() 抛出异常

来自 Activity 的自定义 View 中的 Android 引用方法

python - Kivy 应用程序无法在 Android 手机上运行,​​但可以在计算机上运行

android - 如何在一行 TextView 的左右两侧对齐文本?

java - 引入ExecutorService后TextView setText不起作用

android - 换行时如何隐藏文字?

Android TextView 禁用颜色更改

android - 修改大字符串的内容

android - textview的背景图片