Whenever I attempt to set content view after dismissing the progress dialog I get an error like…
04-13 14:40:38.043: WARN/System.err(801): android.view.ViewRoot$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views.
04-13 14:40:38.073: WARN/InputManagerService(59): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@44dde3f0
My code is like…
ProgressDialog dialog = null; //class variable.
dialog = ProgressDialog.show(Login.this, "",
"Logging you in. Please wait...", true);
new Thread() {
public void run() {
try{
//serious work here!
}
dialog.dismiss();
setContentView(R.layout.blaa);
} catch (Exception e) {
e.printStackTrace();
}
}
}.start();
What’s causing this?
Your Thread are not the UI-thread. I think you need to create a Handler and then post a Runnable to it when you need to switch content view.