AlertDialog 自定义样式
2014-08-02 14:44
489 查看
废话不多说了,只是做个笔记,以后忘了才可以查看下,我一般都不不去记这些方法的,知道了就好,要用的时候查下就可以了。
关键性代码:
你要显示的布局文件
pupwindow_login_error.xml
关键性代码:
/** * 用户名或密码错误的弹窗 * 网络状况不好的弹窗 */ public void show_login_error(String err_text){ final AlertDialog dlg = new AlertDialog.Builder(this).create(); dlg.show(); Window window = dlg.getWindow(); // *** 主要就是在这里实现这种效果的. // 设置窗口的内容页面,login_error_butt.xml文件中定义view内容 window.setContentView(R.layout.pupwindow_login_error); Button login_err = (Button) window.findViewById(R.id.login_error_butt); TextView text=(TextView) window.findViewById(R.id.login_error_text); text.setText(err_text); login_err.setOnClickListener(new OnClickListener() { @Override public void onClick(final View v) { dlg.dismiss(); } }); }
你要显示的布局文件
pupwindow_login_error.xml
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/login_popup_bg" android:orientation="vertical" > <TextView android:id="@+id/login_error_text" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="5dp" android:gravity="center_horizontal" android:text="账号或密码错误" android:textSize="18sp" /> <View android:layout_width="match_parent" android:layout_height="2dp" android:layout_marginRight="5dp" android:layout_marginLeft="5dp" android:background="#d2d2d2" /> <Button android:id="@+id/login_error_butt" android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center_horizontal|center_vertical" android:text="确定" android:background="@null" /> </LinearLayout>
相关文章推荐
- AlertDialog自定义样式
- 【转】bootbox自定义dialog、confirm、alert样式,以及基本设置方法setDefaults中可用参数
- 自定义AlertDialog button的样式
- android AlertBuilder创建的dialog,使用自定义样式
- AlertDialog自定义样式
- bootbox自定义dialog、confirm、alert样式,以及基本设置方法setDefaults中可用参数
- AlertDialog自定义样式问题
- 修改系统AlertDialog样式、自定义Dailog-----Activity透明效果
- AlertDialog自定义样式
- AlertDialog自定义样式
- AlertDialog自定义样式显示圆角背景失败
- bootbox自定义dialog、confirm、alert样式,以及基本设置方法setDefaults中可用参数
- bootbox自定义dialog、confirm、alert样式,以及基本设置方法setDefaults中可用参数
- AlertDialog 自定义样式
- ProgressDialog,SharedPreferences,Toast自定义,versionName ,new AlertDialog.Builder和下载更新
- AlertDialog_对话框_最全用法详解_自定义布局和适配器
- Android alertdialog的自定义添加按钮和添加点击
- 改变support中AlertDialog的样式
- 自定义AlertDialog
- Android-->Dialog/DialogFragment宽度高度修改/全屏,自定义样式