在程序执行到一个进度条对话框,如果需要点击手机上的返回键想回到上一个activity,则需要这样处理:
package com.gem.hsx.progress;
import android.app.Activity;
import android.app.ProgressDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.view.KeyEvent;
public class TestBack extends Activity {
ProgressDialog mypDialog;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.progressdialog_background);
mypDialog=new ProgressDialog(TestBack.this);
mypDialog.setIndeterminate(false);
mypDialog.setCanceledOnTouchOutside(false);
mypDialog.setTitle("加载中");
mypDialog.setButton("取消", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface d