Android——加载中的dialog
来源:互联网 发布:锐捷网络 编辑:程序博客网 时间:2024/06/04 18:33
1、自定义dialog
java:
public class CustomProgressBar extends Dialog { private Context context ; private String progressText ; public CustomProgressBar(Context context) { super(context , R.style.dialog_theme) ; this.context = context ; } public CustomProgressBar(Context context, String progressText) { super(context, R.style.dialog_theme) ; this.context = context ; this.progressText = progressText ; } @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.custom_progressbar) ; TextView title = (TextView) findViewById(R.id.custom_imageview_progress_title); title.setText(progressText == null ? "加载数据中,请稍后..." : progressText) ; } /** * @see android.app.Dialog#show() */ @Override public void show() { try{ if(!isShowing()){ super.show(); } }catch (Exception e){ e.printStackTrace(); } ImageView im = (ImageView) findViewById(R.id.custom_imageview_progress_bar); im.startAnimation(AnimationUtils.loadAnimation(context, R.anim.round_loading)); }}
xml:custom_progressbar.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:padding="15dip" android:gravity="center" android:background="@drawable/shen" android:orientation="vertical" > <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/custom_imageview_progress_bar" android:src="@drawable/diaog" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="5dip" android:id="@+id/custom_imageview_progress_title" android:textColor="@android:color/white" android:textSize="12sp" /></LinearLayout>2、在res文件夹下新建一个动画round_londing.xml<?xml version="1.0" encoding="utf-8"?><rotate xmlns:android="http://schemas.android.com/apk/res/android" android:duration="1000" android:fromDegrees="0" android:interpolator="@android:anim/linear_interpolator" android:pivotX="50%" android:pivotY="50%" android:repeatCount="infinite" android:toDegrees="+360"></rotate>3、在style里加入<style name="dialog_theme"> <item name="android:windowFrame">@null</item> <item name="android:windowContentOverlay">@null</item> <item name="android:windowIsFloating">true</item> <item name="android:windowIsTranslucent">true</item> <item name="android:windowNoTitle">true</item> <item name="android:windowAnimationStyle">@android:style/Animation.Dialog</item> <item name="android:windowBackground">@color/transparent</item> <!-- 背景透明 --> <!-- 激活背景变暗遮罩 --> <item name="android:backgroundDimEnabled">true</item> <item name="android:backgroundDimAmount">0.6</item></style>
4、在要调用dialog的java中
CustomProgressBar cd;//dialog开始调用此方法public void createProgressBar() { this.createProgressBar(null);}//dialog中public void createProgressBar(String text) { if (cd== null) { if (text == null) { cd= new CustomProgressBar(this); } else { cd= new CustomProgressBar(this, text); } cd.setCancelable(true); } if (!cd.isShowing()) { cd.show(); }}//dialog结束调用此方法public void disMissProgress() { if (cd!= null && cd.isShowing()) { cd.dismiss(); }}5、这样就可以了测试一下吧,图片我就不贴了,自己找两张就ok;
2 0
- Android——加载中的dialog
- android 加载等待Dialog
- android中的dialog
- android中的Dialog相关
- Android中的常用Dialog
- Android中的dialog窗口
- 盘点android中的dialog
- Android中的Dialog对话框
- 盘点android中的dialog
- Android中的Dialog
- Android 自定义加载框dialog
- Android 之自定义加载Dialog
- Android自定义加载中Dialog
- Android开发——Dialog
- Android UI——Dialog
- Android学习——Dialog
- Android—Dialog标题居中
- 从零开始学android:Android中的基本控件(下) —— 对话框:Dialog
- There was an error pushing a new version to trunk: getaddrinfo: nodename nor servname provided, or n
- Debug和Release区别
- python技巧
- Navicat for PostgreSQL 运算符有哪些类别
- Sketch真的很难上手?
- Android——加载中的dialog
- CentOS7安装PostgreSQL9.5过程
- Android开发笔记(八十六)几个特殊的类
- EasyUI tree 相关
- Mac 升级 OpenSSL 安装 Tengine
- 单链表插入删除
- 关于java字符串的内存问题
- 杂记
- recycleView的理解(UNDone)