when I put the setContentView in thread as below, it crashes while running in emulator.
new Thread(){
public void run() {
setContentView(R.layout.main_layout);
}
}.start();
when I put the setContentView in thread as below, it crashes while running in emulator.
new Thread(){
public void run() {
setContentView(R.layout.main_layout);
}
}.start();
that is because setContentView cannot be called from a non-UI thread.
You could try...
runOnUiThread(new Runnable(){
public void run() {
setContentView(R.layout.main_layout);
}});
.. but be careful as the convention is to do setContentView(..);
in onCreate()
on the default thread there.