AlertDialog alertDialog = new AlertDialog
.Builder(this)
.setTitle("请点击播放的舞美效果")
//列表选择
.setItems(danceName, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
tcpClient.setCode(getOne(danceName[which]).getCode());
tcpClient.tcpStart();
mSpinnerEight.setText(danceName[which]);
try {
Field field = dialog.getClass().getSuperclass().getDeclaredField("mShowing");
field.setAccessible(true);
//设置mShowing值,欺骗android系统
field.set(dialog, false);
} catch (Exception e) {
e.printStackTrace();
}
}
})
.setPositiveButton("关闭",
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
try {
Field field = dialog.getClass().getSuperclass().getDeclaredField("mShowing");
field.setAccessible(true);
//设置mShowing值,欺骗android系统
field.set(dialog, true);
} catch (Exception e) {
e.printStackTrace();
}
dialog.dismiss();
}
}).create();
alertDialog.show();
Window dialogWindow = alertDialog.getWindow();
dialogWindow.setGravity(Gravity.BOTTOM | Gravity.LEFT);
dialogWindow.setFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL,WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL);//恢复dialog区域外部的功能
dialogWindow.setDimAmount(0f);//去除遮罩层
WindowManager.LayoutParams lp = dialogWindow.getAttributes();
lp.width=1008;//定义宽度
lp.height=900;//定义高度
lp.x = 61;
lp.y = 100; //设置出现的高度,距离底部
dialogWindow.setAttributes(lp);