标签:attr dial pes void sys miss 弹窗 att smi
public void showList(List<DictValueListBean> response) {
if (!ListUtil.isEmpty(response)) {
List<String> nameList = new ArrayList<>();
for (int i = 0; i < response.size(); i++) {
nameList.add(response.get(i).getLabel());
}
//名字
mItems = nameList.toArray(new String[nameList.size()]);
} else {
mItems = new String[]{"暂无"};
}
String tittle;
AlertDialog.Builder alertBuilder = new AlertDialog.Builder(this);
if ("1".equals(mCliskStatus)) {
tittle = "单位类型";
} else {
tittle = "客户性质";
}
alertBuilder.setTitle(tittle);
alertBuilder.setItems(mItems, (dialogInterface, i) -> {
//设置返回参数
if (!"暂无".equals(mItems[i])) {
if ("1".equals(mCliskStatus)) {
//客户类型赋值
mTvCustmomerTypeSet.setText(mItems[i]);
//客户类型数据字典
mTypeCode = response.get(i).getValue();
} else {
//客户性质赋值
mTvCustmomerNatureSet.setText(mItems[i]);
//客户性质数据字典
mStatusCode = response.get(i).getValue();
}
} else {
if ("1".equals(mCliskStatus)) {
//客户类型赋值
mTvCustmomerTypeSet.setText("");
} else {
//客户性质赋值
mTvCustmomerNatureSet.setText("");
}
}
mAlertDialog.dismiss();
});
mAlertDialog = alertBuilder.create();
mAlertDialog.show();
//获取屏幕大小
WindowManager wm = (WindowManager) this.getSystemService(Context.WINDOW_SERVICE);
DisplayMetrics dm = new DisplayMetrics();
assert wm != null;
wm.getDefaultDisplay().getMetrics(dm);
// 屏幕宽度(像素)
int width = dm.widthPixels;
// 屏幕高度(像素)
int height = dm.heightPixels;
WindowManager.LayoutParams params = Objects.requireNonNull(mAlertDialog.getWindow()).getAttributes();
params.width = (int) (0.65 * width);
//判断返回条数,设计弹窗显示大小
if (response.size() < 10) {
params.height = WindowManager.LayoutParams.WRAP_CONTENT;
} else {
params.height = (int) (0.6 * height);
}
mAlertDialog.getWindow().setAttributes(params);
}
标签:attr dial pes void sys miss 弹窗 att smi
原文地址:https://www.cnblogs.com/sunjian43792901/p/13231209.html