让用户等待执行完。
import android.widget.PopupWindow; //新建实例 final PopupWindow popupWindow = new PopupWindow(); //显示 popupWindow.setOutsideTouchable(false); popupWindow.setFocusable(false);//点击区域外不会消失,点击返回会执行back事件 popupWindow.setHeight(ViewGroup.LayoutParams.WRAP_CONTENT); popupWindow.setWidth(ViewGroup.LayoutParams.WRAP_CONTENT); View view = LayoutInflater.from(MainActivity.this).inflate(R.layout.popup,null); popupWindow.setContentView(view); popupWindow.showAtLocation(getWindow().getDecorView(), Gravity.CENTER,0,0); //消失 popupWindow.dismiss();
popup.xml
另外常用
//用户选择对话框
new alertDialog.Builder(this)
.setTitle("提示")
.setMessage("是否人为结束,重新开始?")
.setPositiveButton("确定", new DialogInterface.onClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
//点确定要执行的内容
}
})
.setNegativeButton("取消", null).show();



