AlertDialog弹出对话框(奶瓶)

2018-01-30  本文已影响0人  _奶瓶

一,简单的使用方法

AlertDialog.Builder aDlog = new        AlertDialog.Builder(cloudListActivity.this,AlertDialog.THEME_HOLO_LIGHT);
                    aDlog.setTitle("标题");
                    aDlog.setIcon(R.drawable.app_icon);
                    aDlog.setMessage("内容内容内容内容内容内容内容内容");
                    aDlog.setPositiveButton("确认",new DialogInterface.OnClickListener() {
                        
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            // TODO Auto-generated method stub
                            
                            
                        }
                    });
                    aDlog.setNegativeButton("取消", new DialogInterface.OnClickListener()
                        {
                            public void onClick(DialogInterface dialog, int which)
                            {
                          
                            }
                        });

                //展示
                    aDlog.show();
            }

拓展:
<AlertDialog 主题颜色>

传统主题:

AlertDialog.Builder builder = new     AlertDialog.Builder(DialogActivity.this,AlertDialog.THEME_TRADITIONAL)

深黑色主题:

AlertDialog.Builder builder = new AlertDialog.Builder(DialogActivity.this,AlertDialog.THEME_HOLO_DARK);

蓝色主题:

AlertDialog.Builder builder = new AlertDialog.Builder(DialogActivity.this,AlertDialog.THEME_HOLO_LIGHT);

深色主题:

AlertDialog.Builder builder = new AlertDialog.Builder(DialogActivity.this,AlertDialog.THEME_DEVICE_DEFAULT_DARK);

浅蓝主题:

AlertDialog.Builder builder = new AlertDialog.Builder(DialogActivity.this,AlertDialog.THEME_DEVICE_DEFAULT_LIGHT);

系统自带的不满意的话,还可以自定义style

<style name="AlertDialog" parent="@android:Theme.DeviceDefault.Light.Dialog">  
<!-- 这里设置背景为透明,为了隐藏边框 -->  
    <item name="android:windowBackground">@android:color/transparent</item>  
    <item name="android:windowNoTitle">true</item>  
<!-- 这里是修改顶部标题背景颜色,具体颜色自己定,可以是图片 -->  
    <item name="android:topDark">@color/white</item>  
 <!-- 这里是修改内容区域背景颜色 -->  
<item name="android:centerDark">@color/white</item>  
    <item name="android:windowIsTranslucent">true</item>  
    <item   name="android:windowAnimationStyle">@+android:style/Animation.Translucent</item>  
</style>    
上一篇 下一篇

猜你喜欢

热点阅读