ProgressDialog(进度条对话框)
拥有ProgressBar 的属性
ProgressDialog progressDialog = new ProgressDialog();
progressDialog .setIndeterminate(true);//设置不确定性,为true 是不确定性, false为确定
progressDialog .setProgressDrawable(..); //自定义进度条样式
progressDialog .setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);//设置水平. 水平的线或者圈
progressDialog .show(); //弹出对话框
<span style="font-size:14px;">final ProgressDialog dialog = new ProgressDialog(this); dialog.setTitle("refresh....."); dialog.setMessage("进度"); dialog.setIcon(R.drawable.ic_launcher); dialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); dialog.setProgressDrawable(getResources().getDrawable( R.drawable.line_hori_progressbar_layer_list)); dialog.setIndeterminate(false); dialog.setButton(ProgressDialog.BUTTON_POSITIVE, "confirm", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { Toast.makeText(DialogActivity.this, "" + which, Toast.LENGTH_SHORT).show(); } }); dialog.setButton(ProgressDialog.BUTTON_NEGATIVE, "cancel", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { Toast.makeText(DialogActivity.this, "" + which, Toast.LENGTH_SHORT).show(); } }); new Thread(new Runnable() { //模拟线程让他加载 @Override public void run() { for (int i = 0; i <= 100; i++) { dialog.setProgress(i); try { Thread.sleep(100); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } }).start(); dialog.show();</span>
DatePickerDialog
DatePickerDialog dateDialog = new DatePickerDialog(context,new onDateSetListener(),int year,int month,int day);
dateDialog .show();
ps: 以下监听中的参数,设置的是2015/10/15, 对话框中显示的是11月,打印出来是10,显示 出来的月份需要加1
Calendar calendar = Calendar.getInstance(); int years = calendar.get(Calendar.YEAR); int month = calendar.get(Calendar.MONTH); int day = calendar.get(Calendar.DAY_OF_MONTH); DatePickerDialog dateDialog = new DatePickerDialog(this, new OnDateSetListener() { @Override public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) { } }, years, month, day);
Toast.makeText(context,"objtext","Toast.LENGTH_SHORT").show();
有setview()方法,可以自定义对话框
Toast toast = new Toast(context);
View v = inflater.inflate(R.layout....);
toast.setView(v);
//下面的布局是自定义alertdialog的布局,效果同自定义alertdialog一样
<span style="font-size:14px;">Toast toast = new Toast(DialogActivity.this); toast.setView(LayoutInflater.from(DialogActivity.this).inflate( R.layout.dialog_alert_d_layout, null)); toast.setGravity(Gravity.CENTER, 0, 0); toast.show();</span>