android开发步步为营之91:自定义AlertDialog
来源:互联网 发布:软件企业认证时间 编辑:程序博客网 时间:2024/04/28 03:41
第一步:自定义view
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="15dp" android:background="#ffffff" android:orientation="vertical"> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="15dp" android:text="@string/lbl_enable_flash_kb" android:textAlignment="center" android:textColor="#282828" android:textSize="18sp" android:textStyle="bold" /> <ImageView android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginEnd="15dp" android:layout_marginLeft="15dp" android:layout_marginRight="15dp" android:layout_marginStart="15dp" android:src="@drawable/ic_enable_flashkb" /> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginEnd="15dp" android:layout_marginLeft="15dp" android:layout_marginRight="15dp" android:layout_marginStart="15dp" android:layout_marginTop="20dp" android:text="@string/lbl_protect_privacy" android:textColor="#666666" android:textSize="15sp" /> <View android:layout_width="match_parent" android:layout_height="1dp" android:layout_marginEnd="15dp" android:layout_marginLeft="15dp" android:layout_marginRight="15dp" android:layout_marginStart="15dp" android:layout_marginTop="15dp" android:background="#E2E6E8"></View> <RelativeLayout android:id="@+id/layout_ok" android:layout_width="match_parent" android:layout_height="50dp" android:layout_marginEnd="15dp" android:layout_marginLeft="15dp" android:layout_marginRight="15dp" android:layout_marginStart="15dp" android:gravity="center"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerInParent="true" android:text="@string/ok" android:textColor="#557df9" android:textSize="18sp" /> </RelativeLayout> </LinearLayout></LinearLayout>
第二步:方法调用
private void showProtectPrivacyDialog() { View root = LayoutInflater.from(this).inflate(R.layout.layout_privacy_dialog, null); final AlertDialog alertDlg = new AlertDialog.Builder(this).create(); RelativeLayout layoutOk = (RelativeLayout) root.findViewById(R.id.layout_ok); layoutOk.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { alertDlg.dismiss(); } }); alertDlg.show(); alertDlg.setContentView(root); }
1 0
- android开发步步为营之91:自定义AlertDialog
- android开发步步为营之95:自定义dialog去掉白色边框
- android开发步步为营之99:使用自定义字体
- android开发步步为营之33:玩转对话框AlertDialog
- android开发步步为营之93:android自定义view开发之一(验证码生成器)
- Android开发之AlertDialog和自定义AlertDialog
- android开发步步为营之28:自定义Menu
- android开发步步为营之2:开发自定义进度条对话框
- android开发步步为营之25:开发自定义进度条对话框
- android开发步步为营之3:自定义控件之手势签名
- android开发步步为营之96:android两种常用截图技术
- android开发步步为营之88:基于LruCache和AsyncTask的网络相册开发
- android开发步步为营之64:PopupWindow实现自定义弹出菜单
- android开发步步为营之78:自定义样式ProgressBar
- android开发步步为营之108:下载断点续传
- 【Android开发】自定义AlertDialog
- android开发步步为营之94:使用PathEffect画虚线和虚线框
- android开发步步为营之105:解决键盘弹起页面被顶上去问题
- 图片整理
- Web端直传实践
- 避免 EditText 弹出软键盘的处理方法
- iOS post请求图片Base64编码上传
- HTML服务器控件与Web服务器控件
- android开发步步为营之91:自定义AlertDialog
- JVM 工作原理
- view 的滑动冲突
- FMDB简单介绍
- Java 基础——构造器和方法的区别
- linux上安装使用maven
- eclipse经典快捷键
- uboot解析
- FMDB数据库队列