一、dialog在使用的過程當中java
在Activity的onPause和onDestory方法中,要將dialog dismiss掉。android
不然最後會報錯。具體的錯誤內容以下:app
Activity com.etu.setest.MainActivity has leaked window com.android.internal.policy.PhoneWindow$DecorView{52d227d V.E...... R.....I. 0,0-960,96} that was originally added here at android.view.ViewRootImpl.<init>(ViewRootImpl.java:399) at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:330) at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:106) at android.app.Dialog.show(Dialog.java:346) at com.etu.setest.MainActivity$onItemClick.onItemClick(MainActivity.java:87) at android.widget.AdapterView.performItemClick(AdapterView.java:314) at android.widget.AbsListView.performItemClick(AbsListView.java:1162) at android.widget.AbsListView$PerformClick.run(AbsListView.java:3102) at android.widget.AbsListView$3.run(AbsListView.java:3967) at android.os.Handler.handleCallback(Handler.java:743) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:150) at android.app.ActivityThread.main(ActivityThread.java:5665) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:799) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:689)