我想在我的应用加载一些数据时显示一个旋转轮对话框:

按钮单击时应显示旋转轮对话框.我正在使用下面的代码,但它现在显示了旋转轮.可能是什么问题呢?
public void CheckAccount(String username, String password) {
try {
final ProgressDialog progDailog = ProgressDialog.show(this,
"Progress_bar or give anything you want",
"Give message like ....please wait....", true);
new Thread() {
public void run() {
try {
// sleep the thread, whatever time you want.
sleep(1000);
} catch (Exception e) {
}
progDailog.dismiss();
}
}.start();
//getting data code here
//getting data code here
//getting data code here
//getting data code here
//getting data code here
} catch (Exception e) { …Run Code Online (Sandbox Code Playgroud) 我正在开发我的第一个Android应用程序,我需要显示ProgressDialog,而后台任务,在这种情况下只是服务器上的http调用.我对此进行了一些研究,并且已经检查了与此主题相关的其他线程.
http://developer.android.com/reference/android/os/AsyncTask.html
Android显示ProgressDialog,直到活动UI完成加载
http://android-developers.blogspot.com/2009/05/painless-threading.html
其中包括.
比起我要编写一些代码:
1)在My Activity中,我声明一个变量为ProgressDialog类型
public class LoginActivity extends Activity {
public static final String TAG = "LoginActivity";
protected ProgressDialog progressDialog;
...
Run Code Online (Sandbox Code Playgroud)
2)我还编写了一个内部类来根据需要扩展AsyncTask,这里我在doInBackGround中调用静态方法,它实际上向服务器发出POST http请求,在服务器端我已经阻止服务器响应20s验证进度对话框.
class EfetuaLogin extends AsyncTask<Object, Void, String> {
private final static String TAG = "LoginActivity.EfetuaLogin";
@Override
protected void onPreExecute()
{
Log.d(TAG, "Executando onPreExecute de EfetuaLogin");
}
@SuppressWarnings("unchecked")
@Override
protected String doInBackground(Object... parametros) {
Log.d(TAG, "Executando doInBackground de EfetuaLogin");
Object[] params = parametros;
HttpClient httpClient = (HttpClient) params[0];
List<NameValuePair> listaParametros = …Run Code Online (Sandbox Code Playgroud)