开发者

Access to textview from threads

I have an activity with a textview, created from the layout.xml. Inside this activity I created a thread. I want want to use my textview from inside the thread but each time I d开发者_运维百科o something like textview.setText() my program forces to close.

The question is : why I cannot access to textview from the thread ?


The problem is You are trying to interfere in Ui Thread from a non UI thread so in order to do such things from non ui- thread

    runOnUiThread(new Runnable()
    {            
        @Override
        public void run()
        {
            // Add your GUI code here  like setText from your perspective              
        }
    });
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜