The first problem was that the ProgressDialog was not showing. Then I read that I should create a Thread. I created the Thread and it worked. But now I can't dismiss the ProgressDialog. The app crashes, the screen goes black.
xGrava.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
final ProgressDialog PD = ProgressDialog.show(NovaOcc.this,"","");
PD.setContentView(R.layout.ipp_load);
PD.getWindow().setBackgroundDrawableResource(android.R.color.transparent);
Thread mThread = new Thread() {
@Override
public void run() {
if (ValidaDados() == true) {
if (GravaDados() == true) {
xGrava.setVisibility(View.GONE);
PD.dismiss();
}
}
}
};
mThread.start();
}
});