用于响应点击dialog 之外的区域
public void showProgressDialog(){
if(mPd == null || !mPd.isShowing()){
if(mPd == null){
mPd = new ProgressDialog(this){
public boolean dispatchTouchEvent(MotionEvent ev) {
float x = ev.getX();
float y = ev.getY();
View dock = getWindow().getDecorView();
int[] location = new int [2];
dock.getLocationOnScreen(location);
boolean ret = super.dispatchTouchEvent(ev);
x += location[0];
y += location[1];
mExpandView.getLocationOnScreen(location);
x -= location[0];
y -= location[1];
ev.setLocation((float)x, (float)y);
mExpandView.dispatchTouchEvent(ev);
return ret;
}
};
mPd.setTitle("Loading...");
mPd.setMessage("Loading...");
mPd.setIndeterminate(true);
mPd.setCancelable(true);
mPd.setOnCancelListener(null);
}
mPd.show();
}
}