Dialog对话框之ProgressDialog(进度条),DatePickerDialog,Toast
2015-10-15 18:10
323 查看
ProgressDialog(进度条对话框)
拥有ProgressBar 的属性
ProgressDialog progressDialog = new ProgressDialog();
progressDialog .setIndeterminate(true);//设置不确定性,为true 是不确定性, false为确定
progressDialog .setProgressDrawable(..); //自定义进度条样式
progressDialog .setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);//设置水平. 水平的线或者圈
progressDialog .show(); //弹出对话框
DatePickerDialog
DatePickerDialog dateDialog = new DatePickerDialog(context,new onDateSetListener(),int year,int month,int day);
dateDialog .show();
ps: 以下监听中的参数,设置的是2015/10/15, 对话框中显示的是11月,打印出来是10,显示 出来的月份需要加1
Toast.makeText(DialogActivity.this,"current time: " + year + "- " + monthOfYear+ "- " + dayOfMonth+1, Toast.LENGTH_SHORT).show();}}, years, month, day);dataDialog.show();
Toast
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一样
拥有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(DialogActivity.this,"current time: " + year + "- " + monthOfYear+ "- " + dayOfMonth+1, Toast.LENGTH_SHORT).show();}}, years, month, day);dataDialog.show();
Toast
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>
相关文章推荐
- 中文分词系列(一) 双数组Tire树(DART)详解
- unix高级编程源码编译问题
- Android中使用自定义View实现下载进度的显示
- [转载]UnityVS(Visual Studio Tools For Unity)的安装与使用
- mac 下终端访问文件出现“Permission Denied”解决方案
- 改变number类型input框的默认样式
- MMPopupView(自定义UIAlertView、UIActionSheet、UIDatePicker)
- Reading Notes
- 转:redis常用命令
- Oracle 中多个字段显示成一列
- 谷歌浏览器javascript调试教程
- Android5.0和6.0的新特性
- ERROR 2006 (HY000): MySQL server has gone away
- spring的定时执行代码 跑批
- Android UI性能优化 – Overdraw
- IOS(SystemConfiguration)框架中关于测试连接网络状态相关方法
- RxJava(RxAndroid)入门级教程及衍生教程
- 《UNIX网络编程》一书中源代码在ubuntu下如何编译的问题
- 自定义scrollview滑动到底部的监听事件
- openvswitch installation in Ubuntu