简单的警告对话框

1.布局文件
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="250dp" android:layout_height="wrap_content" android:layout_gravity="center" android:background="@drawable/application_white_icon" android:gravity="center" android:orientation="vertical" >

    <TextView  android:layout_width="match_parent" android:layout_height="35dp" android:gravity="center" android:text="亲,你办理入住后才可以使用!" android:textColor="#8f8f8f" android:textSize="16sp" />

    <ImageView  android:layout_width="match_parent" android:layout_height="2dp" android:layout_marginTop="8dp" android:background="@drawable/application_pressed_darkblue_default_green_selector" />

    <TextView  android:id="@+id/addsuccesstext" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginRight="10dp" android:gravity="right" android:text="\n知道了\n" android:textColor="#8f8f8f" android:textSize="22sp" />

</LinearLayout>
 2.values文件夹里面的sytle.xml文件
 <!-- Dialog对话框的样式 -->
    <style name="CustomDialogTheme" parent="@android:style/Theme.Dialog">
    <item name="android:windowIsFloating">true</item>
    <item name="android:windowNoTitle">true</item>
    <item name="android:windowBackground">@android:color/transparent</item>
    <item name="android:windowAnimationStyle">@android:style/Animation.Dialog</item>
    <item name="android:windowSoftInputMode">stateUnspecified|adjustPan</item>
    <item name="android:fitsSystemWindows">true</item>
    </style>
3.弹出警告对话框的方法
    /** * 弹出警告话框 */
    public void popupAlertDialog() {

        // 自定义是否退出程序的对话框
        final Dialog alertdialog = new Dialog(mContext, R.style.CustomDialogTheme);
        alertdialog.getWindow();
        alertdialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
        alertdialog.setContentView(R.layout.application_dialog_exit_application);
        alertdialog.setCancelable(false);

        alertdialog.show();// 弹出对话框
        Handler mHandler = new Handler();
        mHandler.postDelayed(new Runnable() {
            @Override
            public void run() {
                alertdialog.dismiss();
            }
        }, ConstantsMember.AGAIN_CONTROL_SWITCH_TIME);
    }

你可能感兴趣的:(对话框,简单对话框,警告对话框)