alertdialog|alertdialog 自定义view 以及反射
Viewview = (LinearLayout) getLayoutInflater().inflate(R.layout.outlayout,null);
AlertDialog.Builder builder =new AlertDialog.Builder(DataActivity1.this);
builder.setTitle("导出数据");
builder.setView(view);
final EditText 文件名 = (EditText)view.findViewById(R.id.fileName);
文件名.setText(nowTime);
//相当于点击确认按钮
builder.setPositiveButton("确认", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {String fileName = 文件名.getText() + "";
if (fileName.length() < 1){
try {
Field field = dialog.getClass().getSuperclass().getDeclaredField("mShowing");
field.setAccessible(true);
field.set(dialog, false);
} catch (Exception e) {
e.printStackTrace();
}
}else{
try {
Field field = dialog.getClass().getSuperclass().getDeclaredField("mShowing");
field.setAccessible(true);
field.set(dialog, true);
} catch (Exception e) {
e.printStackTrace();
}ExcelOperTest ex = new ExcelOperTest();
try {
ex.DataWrite2Excel(DataActivity1.dataList,fileName + ".xls");
Toast.makeText(DataActivity1.this, "导出成功!",
Toast.LENGTH_SHORT).show();
} catch (IOException e) {
e.printStackTrace();
Toast.makeText(DataActivity1.this, "导出失败!",
Toast.LENGTH_SHORT).show();
} catch (WriteException e) {
e.printStackTrace();
Toast.makeText(DataActivity1.this, "导出失败!",
Toast.LENGTH_SHORT).show();
}
}}
});
//相当于点击取消按钮
builder.setNegativeButton("取消", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub}
});
builder.create();
builder.show();
【alertdialog|alertdialog 自定义view 以及反射】//布局
推荐阅读
- SpringBoot调用公共模块的自定义注解失效的解决
- python自定义封装带颜色的logging模块
- 列出所有自定义的function和view
- tableView|tableView 头视图下拉放大 重写
- 记录iOS生成分享图片的一些问题,根据UIView生成固定尺寸的分享图片
- Flutter的ListView
- OC:|OC: WKWebView详解
- Spring|Spring Boot 自动配置的原理、核心注解以及利用自动配置实现了自定义 Starter 组件
- Swift|Swift ----viewController 中addChildViewController
- WKWebview|WKWebview js 调用oc 和oc调用js