标签:override list inter nbsp date 设置 int day can
1、Dialog的使用
【1】AlertDialog的使用
1)新建一个AlertDialog.Builder对象
AlertDialog.Builder ad = new AlertDialog.Builder(this);
2)设置标题
ad.setTitle("It‘s Pitch Black");
3)设内容
ad.setMessage("HelloWorld");
4)加按钮
ad.setPositiveButton("Back",new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { System.out.println("Back"); } }); ad.setNegativeButton("Next", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { System.out.println("Next"); } });
5)设可取消(可以不设置)
ad.setCancelable(true); ad.setCancelable(true); ad.setOnCancelListener(new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { System.out.println("Cancel"); } });
6)show展示
ad.show();
【2】特殊的输入Dialog
1)DatePickerDialog 可以让用户选择一个日期
Calendar calendar = Calendar.getInstance(); DatePickerDialog dialog = new DatePickerDialog(this, TRIM_MEMORY_RUNNING_LOW, new DatePickerDialog.OnDateSetListener() { @Override public void onDateSet(DatePicker view, int year, int month, int dayOfMonth) { // TODO Auto-generated method stub } }, calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH),calendar.get(Calendar.DAY_OF_MONTH)); dialog.show();
更加详细:参考该博客
2)
标签:override list inter nbsp date 设置 int day can
原文地址:https://www.cnblogs.com/lyhcc/p/10325194.html