Android中AlertDialog和ProgressDialog的使用
来源:互联网 发布:三国志11电脑数据bug 编辑:程序博客网 时间:2024/05/16 07:05
1.在布局文件中添加两个按钮:
<Button android:id="@+id/btn_ad" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="AlertDialog" android:onClick="myAlertDialogClick" /><Button android:id="@+id/btn_pd" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="ProgressDialog" android:onClick="myProgressDialogClick" />并绑定按钮的点击事件
2.在活动中实现两个点击事件:
public void myAlertDialogClick(View v){ AlertDialog.Builder dialog = new AlertDialog.Builder(FirstActivity.this); dialog.setTitle("AlertDialog"); dialog.setMessage("我是AlertDialog"); dialog.setCancelable(false); dialog.setPositiveButton("OK", new DialogInterface.OnClickListener(){ @Override public void onClick(DialogInterface dialog, int which) { } }); dialog.setNegativeButton("Cancel", new DialogInterface.OnClickListener(){ @Override public void onClick(DialogInterface dialog, int which) { } }); dialog.show();}public void myProgressDialogClick(View v){ ProgressDialog progressDialog = new ProgressDialog(FirstActivity.this); progressDialog.setTitle("ProgressDialog"); progressDialog.setMessage("Loading..."); progressDialog.setCancelable(true); progressDialog.show();}
其中setCancelable 是控制我按Back键是否可以生效。
效果如图:
AlertDialog
ProgressDialog
0 0
- Android中AlertDialog和ProgressDialog的使用
- 对话框的使用 AlertDialog 和ProgressDialog
- Android开发 - AlertDialog和ProgressDialog的做法实例
- Android中ProgressDialog的使用
- Android中AlertDialog和Toast的使用
- Android中AlertDialog和Toast的使用
- Android中AlertDialog和Toast的使用
- Android中AlertDialog和Toast的使用
- Android 对话框 (AlertDialog & ProgressDialog)
- AlertDialog和ProgressDialog
- ProgressDialog和AlertDialog代码
- Android中AlertDialog的使用
- Android中AlertDialog的使用
- Android 中 AlertDialog的使用
- Android中AlertDialog的使用
- android中ProgressDialog与ProgressBar的使用
- android中ProgressDialog与ProgressBar的使用
- Android中ProgressDialog的简单使用.
- poj-2431Expedition(加油站 优先队列)
- 15 个 Android 通用流行框架大全
- android数据传递(二)之activity带返回值的跳转,模拟登陆注册
- Spark History Server配置使用
- CSS瀑布流模型
- Android中AlertDialog和ProgressDialog的使用
- 寄存器 cache 内存 硬盘之间的千丝万缕
- Wunder Fund Round 2016 C. Constellation(贪心+计算几何)
- PHP 脚步页面防止重复提交
- HDU 1407 测试你是否和LTC水平一样高
- 数据结构实验之链表一:顺序建立链表
- 51Nod-1082-与7无关的数
- Java-算法之二分查找
- Java实现多线程下载