首页  »   Android

Android显示“正在加载,请稍后.”

网友分享于:2018-04-06  浏览:0次
Android显示“正在加载,请稍后...”

如何实现点击按钮,弹出“正在加载数据,请稍候...”对话框,加载完了之后,对话框自动消失呢?

import com.farsunset.ichat.example.R;

import android.os.Bundle;
import android.app.Activity;
import android.app.ProgressDialog;

public class DateReportActivity extends Activity {

  private ProgressDialog progressDialog;
  
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_date_report);

    showProgressDialog("提示", "正在加载......");
  }

  /*
   * 提示加载
   */
  public void showProgressDialog(String title, String message) {
    if (progressDialog == null) {

      progressDialog = ProgressDialog.show(DateReportActivity.this, title,
          message, true, false);
    } else if (progressDialog.isShowing()) {
      progressDialog.setTitle(title);
      progressDialog.setMessage(message);
    }

    progressDialog.show();

  }

  /*
   * 隐藏提示加载
   */
  public void hideProgressDialog() {

    if (progressDialog != null && progressDialog.isShowing()) {
      progressDialog.dismiss();
    }

  }

}

 

相关解决方案

最新解决方案