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
}
});
精彩评论