Possible Duplicate:
Android : CalledFromWrongThreadException;: Only the original thread that created a view hierarchy can touch its views
Now I am working on an application.I want to show a progressbar until i get a true reply from called method.I used the following code.
progressBar = new ProgressDialog(this);
progressBar.setCancelable(true);
progressBar.setMessage("Loading");
progressBar.show();
new Thread(new Runnable() {
@Override
public void run() {
// TODO Auto-generated method stub
final boolean flag= GetFixtureDetailsJsonFunction();
if (flag==true) {
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
e.printStackTrace();
}
progressBar.dismiss();
}
}
}).start();
protected boolean GetFixtureDetailsJsonFunction()
{
//some code
return true;
}
But I am getting the exception
03-14 15:48:23.722: E/AndroidRuntime(910): android.view.ViewRoot$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views.
Please help me friends