效果图
导入方法
1、下载ExitLibrary源码
2、引入到项目中
3、在需要弹出退出提示框的布局文件中插入
<com.haydar.exitlibrary.ExitPopWindow
android:id="@+id/exit"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:focusable="true"
android:visibility="gone" >
</com.haydar.exitlibrary.ExitPopWindow>
4、在activity中new弹出对象
ExitPopWindow exitPopWindow;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.fragment_main);
exitPopWindow = (ExitPopWindow) findViewById(R.id.exit);
}
5、在activity中修改onkeydown
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
// TODO Auto-generated method stub
exitPopWindow.onKeyDown(keyCode, event);
return false;
}
下载地址