android实现进度条ProgressDialog
16lz
2021-01-23
android实现进度条ProgressDialog
声明
private Button a; private ProgressDialog myDialog;
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); a= (Button) this.findViewById(R.id.a);//获取 a.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { myDialog=new ProgressDialog(MainActivity.this);//创建对象 myDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);//设置进度条的样式 myDialog.setTitle("提示"); //设置标题 myDialog.setMessage("数据加载中..."); //设置进度条信息 myDialog.setIcon(R.drawable.abc_ab_share_pack_mtrl_alpha);//设置icon myDialog.setIndeterminate(false);//设置进度条是否不明确 myDialog.setCancelable(true);//设置按返回键取消加载 myDialog.setButton("确定", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { myDialog.cancel();//撤销进度条 } }); myDialog.show(); } });}
以下是xml代码
<Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="New a" android:id="@+id/a" />
更多资讯:http://blog.csdn.net/qq_26849491
更多相关文章
- Activity 模版样式简介
- APIDEMO 字体默认样式
- 【Android】安卓中常用的图片加载方法
- SeerBar样式
- android异步图片加载三之handler+线程池+消息队列模式
- Android 如何使用浏览器去下载app和加载html
- android Style样式
- Android ProgressBar 各种样式大全