protected void onPause() {
super.onPause();
Log.i(TAG,"PAUSE");
}
public void onClick(View view) {
/*AlertDialog.Builder builder = new Builder(this );
builder.setTitle("i am dialog").setMessage("this is a test")
.setPositiveButton("confirm", null).create().show();*/
TestFragment fragement = new TestFragment();
fragement.show(getSupportFragmentManager(), "test");
super.onPause();
Log.i(TAG,"PAUSE");
}
public void onClick(View view) {
/*AlertDialog.Builder builder = new Builder(this );
builder.setTitle("i am dialog").setMessage("this is a test")
.setPositiveButton("confirm", null).create().show();*/
TestFragment fragement = new TestFragment();
fragement.show(getSupportFragmentManager(), "test");
}
点击按钮后,弹出AlertDialog对话框,PAUSE,并没有显示,表明onpause方法并没有执行。当一个Activiyt失去焦点的时候,必然会执行onPause方法,所以可以说,Dialog窗口是Activity的一部分。而DialogFragment,和直接调用AlertDialg,相同,也没有打印log。
getApplicationContext(),如果替换Builder中的构造方法,会报错。