AlertDialog

alertDialog

AlertDialog_第1张图片
U6YA_AXL~V6$E%[email protected]
AlertDialog.Builder builder = new AlertDialog.Builder(this);
        
        builder.setTitle("haha")
               .setMessage("nihaoma")
               .setNegativeButton("cacel", new OnClickListener() {
                
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    // TODO Auto-generated method stub
                    System.out.println("cacel");
                }
            })
               .setPositiveButton("confirm", new OnClickListener() {
                
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    // TODO Auto-generated method stub
                    System.out.println("confirm");
                    
                }
            }).show();

DatePickerDialog

AlertDialog_第2张图片
Q~3AU37JZJUVKX{F}TXZC)S.png
    DatePickerDialog dialog = new DatePickerDialog(MainActivity.this, new OnDateSetListener() {
            
            @Override
            public void onDateSet(DatePicker view, int year, int monthOfYear,
                    int dayOfMonth) {
                // TODO Auto-generated method stub
                
            }
        }, 2017, 2, 12);
        dialog.setOnShowListener(new OnShowListener() {
            
            @Override
            public void onShow(DialogInterface dialog) {
                // TODO Auto-generated method stub
                Toast.makeText(MainActivity.this, "xainshi", 0).show();
            }
        });
        dialog.setOnDismissListener(new OnDismissListener() {
            
            @Override
            public void onDismiss(DialogInterface dialog) {
                // TODO Auto-generated method stub
                Toast.makeText(MainActivity.this, "dismiss", 0).show();
            }
        });
    
        dialog.show();

ProgressDialog

有2种样式

STYLE_HORIZONTAL:

![TG`XY]DYOZRC55%0QALGCE4.png](http://upload-images.jianshu.io/upload_images/935738-7653870c28276ba4.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

    ProgressDialog d = new ProgressDialog(this);
        d.setProgressStyle(1);
        
        d.show();

STYLE_SPINNER 默认的

AlertDialog_第3张图片
)3~$Q8C9O(62PY$1J28YCY8.png
ProgressDialog.show(this, "你好吗", "howareyour?");

TimePickerDialog

AlertDialog_第4张图片
XED}TYI@`V$(D23(3XY6X$7.png
TimePickerDialog p = new TimePickerDialog(this,new OnTimeSetListener() {
            
            @Override
            public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
                // TODO Auto-generated method stub
                
            }
        },13,20,true);
        p.show();

你可能感兴趣的:(AlertDialog)