Handler

Only the original thread that created a view hierarchy can touch its views.
There are other ways to access to the UI from separate threads
fabiodelorenzo
Posts: 65
Joined: Thu Oct 03, 2013 5:54 pm

Handler

Postby fabiodelorenzo » Thu Oct 03, 2013 6:18 pm

Code: Select all

private Handler mHandler = new Handler();
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.gameone);
    res = getResources();
    // pB.setProgressDrawable(getResources().getDrawable(R.drawable.green)); **//Works**
    mHandler.postDelayed(runnable, 1);
}

private Runnable runnable = new Runnable() {
    public void run() {
        pB.setProgressDrawable(getResources().getDrawable(R.drawable.green));
        pB.invalidate(); // maybe this will even not needed - try to comment out
    }
};

Return to “access to the UI from a thread”

Who is online

Users browsing this forum: No registered users and 0 guests