嘗試使用這樣的事情,如果你在onCreate方法,例如登錄項。
public class YourActivity extends Activity {
private static ProgressDialog pd = null;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.your_activity);
YourActivity.this.pd = ProgressDialog.show(YourActivity.this,
"Logging-in..", "Please wait...", true, false);
new DownloadTask().execute(your parameters);
}
private class DownloadImageTask extends AsyncTask<param, param, param> {
protected param doInBackground(param... params) {
//logging-in
}
protected void onPostExecute(your_result) {
if (YourActivity.this.pd != null) {
YourActivity.this.pd.dismiss();
}
}
}
}
您是否正在主線程上執行登錄請求?如果是,請考慮使用AsyncTask並檢查 - > http://developer.android.com/guide/practices/design/responsiveness.html 如果不是,您可以提供一些更多的細節,可能帶有一段代碼? – uaraven 2012-02-19 20:00:54