自定义ProgressDialog
来源:互联网 发布:华为云计算岗位及年薪 编辑:程序博客网 时间:2024/05/29 03:55
CustomProgressDialog.java
import android.app.Dialog;import android.content.Context;import android.graphics.drawable.AnimationDrawable;import android.view.Gravity;import android.widget.ImageView;import android.widget.TextView;public class CustomProgressDialog extends Dialog { private Context context = null; private static CustomProgressDialog customProgressDialog = null; public CustomProgressDialog(Context context) { super(context); this.context = context; } public CustomProgressDialog(Context context, int theme) { super(context, theme); } public static CustomProgressDialog createDialog(Context context) { customProgressDialog = new CustomProgressDialog(context, R.style.CustomProgressDialog); customProgressDialog.setContentView(R.layout.custom_progress_dialog); customProgressDialog.getWindow().getAttributes().gravity = Gravity.CENTER; return customProgressDialog; } public void onWindowFocusChanged(boolean hasFocus) { if (customProgressDialog == null) { return; } ImageView imageView = (ImageView) customProgressDialog.findViewById(R.id.loadingImageView); AnimationDrawable animationDrawable = (AnimationDrawable) imageView.getBackground(); animationDrawable.start(); } public CustomProgressDialog setTitile(String strTitle) { return customProgressDialog; } public CustomProgressDialog setMessage(String strMessage) { TextView tvMsg = (TextView) customProgressDialog.findViewById(R.id.id_tv_loadingmsg); if (tvMsg != null) { tvMsg.setText(strMessage); } return customProgressDialog; }}
custom_progress_dialog.xml
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="horizontal"> <ImageView android:id="@+id/loadingImageView" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/progress_round"/> <TextView android:id="@+id/id_tv_loadingmsg" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_vertical" android:textSize="20dp"/></LinearLayout>
style.customDialog
<style name="CustomDialog" parent="@android:style/Theme.Dialog"> <item name="android:windowFrame">@null</item> <item name="android:windowIsFloating">true</item> <item name="android:windowContentOverlay">@null</item> <item name="android:windowAnimationStyle">@android:style/Animation.Dialog</item> <item name="android:windowSoftInputMode">stateUnspecified|adjustPan</item> </style><style name="CustomProgressDialog" parent="@style/CustomDialog"> <item name="android:windowBackground">@android:color/transparent</item> <item name="android:windowNoTitle">true</item></style>
progress_round.xml
<?xml version="1.0" encoding="utf-8"?><animation-list xmlns:android="http://schemas.android.com/apk/res/android" android:oneshot="false"> <item android:drawable="@mipmap/progress1" android:duration="200"/> <item android:drawable="@mipmap/progress2" android:duration="200"/> <item android:drawable="@mipmap/progress3" android:duration="200"/></animation-list>
Usage
private CustomProgressDialog progressDialog;progressDialog = CustomProgressDialog.createDialog(context);progressDialog.show();if (progressDialog != null) { progressDialog.dismiss(); progressDialog = null;}
阅读全文
0 0
- 【progressDialog】自定义progressDialog
- 自定义ProgressDialog
- 自定义ProgressDialog
- 自定义progressdialog
- 自定义progressDialog
- 自定义ProgressDialog
- 自定义progressdialog
- 自定义progressDialog
- 自定义progressDialog~~~
- 自定义ProgressDialog
- 自定义ProgressDialog
- 自定义ProgressDialog
- 自定义ProgressDialog
- 自定义ProgressDialog
- 自定义progressdialog
- 自定义ProgressDialog
- 自定义ProgressDialog
- ProgressDialog自定义方法
- 字母反转
- Oracle中的几个概念
- mysql概括
- 《推荐系统实践》笔记--第一章:好的推荐系统
- 有趣的 CSS 题目(3): 层叠顺序与堆栈上下文知多少
- 自定义ProgressDialog
- Oracle基本操作十三:函数和包
- SpringMVC学习(二)——SpringMVC架构及组件
- 卷积神经网络秒懂
- Android 6.0 运行时权限处理完全解析
- 找零钱问题
- Spark集群安装及Streaming调试
- Linux环境使用Nexus3搭建Maven私服
- 4-2 多项式求值 (15分)