一个简单的联网等待或者加载数据的dialog 弹框    很实用

先看效果图

首先是activity_main  和  mainactivity 的代码 只是个简单的点击事件

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.example.administrator.dialoganimation.MainActivity">

<Button
    android:id="@+id/btn1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="dianji"/>
</LinearLayout>
package com.example.administrator.dialoganimation;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

public class MainActivity extends AppCompatActivity implements View.OnClickListener {@Override
    protected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Button btn1= (Button) findViewById(R.id.btn1);
        btn1.setOnClickListener(this);

    }@Override
    public void onClick(View v) {switch (v.getId()){case R.id.btn1:final LoadingDialog dialog = new LoadingDialog(MainActivity.this);
                dialog.show();
                break;
        }}
}

然后是引用的

LoadingDialog 
package com.example.administrator.dialoganimation;

import android.app.Dialog;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.TextView;

/**
 * 加载中Dialog
 *
 * @author xm
 */
public class LoadingDialog {String message=null;
    private Dialog dialog;
    private Context context;
    public LoadingDialog(Context context) {this.context = context;
    }public LoadingDialog(Context context, String message) {this.context = context;
        this.message=message;

    }public void show(){dialog = new Dialog(context,R.style.MyDialogStyle);
        View view = LayoutInflater.from(context).inflate(R.layout.load_contacts_dialog,null,false);
        TextView text_loading = (TextView) view.findViewById(R.id.text_loading);
        dialog.setContentView(view);
        dialog.show();
//        if(!StringUtils.isBlank(message)){
//            text_loading.setText(message);
//        }
        WindowManager.LayoutParams lp = dialog.getWindow().getAttributes();
        lp.width =  ViewGroup.LayoutParams.WRAP_CONTENT;
        lp.height = ViewGroup.LayoutParams.WRAP_CONTENT;
        dialog.getWindow().setAttributes(lp);
    }public void dismiss(){if(dialog != null){dialog.dismiss();
        }}
}

资源文件和xml文件

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_height="100dp"
    android:layout_width="200dp"
    android:layout_centerInParent="true"
    android:background="@drawable/bg_custom_toast">
    <LinearLayout android:layout_height="100dp"
        android:layout_width="200dp"
        android:gravity="center"
        android:orientation="horizontal">
        <ProgressBar
            android:layout_width="20dp"
            android:layout_height="20dp"
            android:indeterminateDrawable="@drawable/animateda_rotate_image_progressbar_white"
            android:visibility="visible"
            android:indeterminate="false" />
        <TextView
            android:id="@+id/text_loading"
            android:layout_marginLeft="10dp"
            android:layout_height="wrap_content"
            android:layout_width="wrap_content"
            android:text="正在努力加载"/>
    </LinearLayout>
</RelativeLayout>
<?xml version="1.0" encoding="utf-8"?>
<animated-rotate
    xmlns:android="http://schemas.android.com/apk/res/android"
   android:drawable="@drawable/progressbar_white"
   android:pivotX="50%"
   android:pivotY="50%"
   />

其中progressbar_white

是这样的

到这就结束了  很简单很实用的一个弹框

Android 加载数据或者联网等待的弹框动画相关推荐

  1. jquery,ajax动态从数据库加载数据并自动选中复选框

    ajax动态加载下拉框数据(前端js发送ajax请求,后端查询数据库,得到数据,返回前端),GET,POST,DELETE,PUT上一篇地址 上一篇讲了下拉框,现在说说复选框 先从简单的单选框说起 & ...

  2. Android动画之仿美团加载数据等待时,小人奔跑进度动画对话框(附顺丰快递员奔跑效果)...

    Android动画之仿美团加载数据等待时,小人奔跑进度动画对话框(附顺丰快递员奔跑效果) 首句依然是那句老话,你懂得! finddreams :(http://blog.csdn.net/finddr ...

  3. Android之Launcher分析和修改4——初始化加载数据

    上面一篇文章说了Launcher是如何被启动的,Launcher启动的过程主要是加载界面数据然后显示出来, 界面数据都是系统APP有关的数据,都是从Launcher的数据库读取,下面我们详细分析Lau ...

  4. Android开发之ContentProvider结合LoaderManager加载数据(图文源代码分享)

    ContentProvider作为Android的四大存储方式之一,有着广泛的应用性,它暴露了数据地址,可以让其他应用访问数据,可以用于存储图片.通讯录等信息,这篇博文将详细介绍ContentProv ...

  5. Android开发之通过接口回调机制加载数据(源代码分享)

    Android开发之通过接口回调机制加载数据的简单实现,在实际开发中通过callback方法得到网络加载的数据的使用频率远比通过直接开启线程或异步任务加载数据的频率高的多,这篇文章的代码将简单实现该机 ...

  6. android 之ListView分页效果以及从网络上加载数据一系列的综合运用

    数据分页策略: <1>:用多少查多少 <2>:全部查询出来,再进行分页处理 数据分页的有关算法: (1):起始索引值 = (当前页-1)*每页显示的记录数 (2):结束索引值 ...

  7. Android官方开发文档Training系列课程中文版:后台加载数据之处理CursorLoader的查询结果

    原文地址:http://android.xsoftlab.net/training/load-data-background/handle-results.html 就像上节课所说的,我们应该在onC ...

  8. Android RecyclerView(八)设置自定义 下拉刷新 与 上拉加载数据

    Android RecyclerView(八)设置下拉刷新 与 上拉加载数据 GitHub 项目源码 CSDN 博客说明 智慧安卓App 文章分析 下拉刷新效果 上拉加载数据效果 1 xml布局文件中 ...

  9. Android仿美团加载数据、小人奔跑进度动画对话框(附顺丰快递员奔跑效果)

    我们都知道在Android中,常见的动画模式有两种:一种是帧动画(Frame Animation),一种是补间动画(Tween Animation).帧动画是提供了一种逐帧播放图片的动画方式,播放事先 ...

  10. Android中ListView分页加载数据

    熟悉Android的朋友们都知道,不管是微博客户端还是新闻客户端,都离不开列表组件,可以说列表组件是Android数据展现方面最重要的组件,我们今天就要讲一讲列表组件ListView加载数据的相关内容 ...

最新文章

  1. Gif(2)-加载视图-波纹
  2. 百度AI快车道南京站来了!接力魔都,继续听前沿技术、学最IN的解决方案
  3. BAT Window批量重命名
  4. 信号 09 | 信号概念
  5. 【教程分享】Jmeter入门教程
  6. 保险报业携手万丈金数 探索大数据应用升级
  7. Dubbo学习总结(9)——Apache Dubbo Roadmap 2019
  8. 【对讲机的那点事】解读无管局《回答》:充分理解物联网产业诉求,值得点赞!...
  9. JavaScript和HTML及CSS的通俗解释
  10. android内部培训视频_第三节(3)_常用控件(ViewPager、日期时间相关、ListView)
  11. Arcgis之国土报备(征地Xls)Xls格式批量转shp格式工具
  12. Visual Studio 2013 旗舰版正式版密钥
  13. WEB前端项目实战/酒仙网开发-李强强-专题视频课程
  14. java避免出现科学计数法表示_Java中的浮点数-科学计数法-加减乘除
  15. 修改数据库表字段报错:1265-data truncated for column
  16. HTTP状态码(重定向/error 301/302)
  17. Web前端 | HTML表单form
  18. 五彩斑斓的黑,找到了
  19. 【random库与math库】python程序对一组随机数求平均值,标准差,中位数,离差,离差方,总体方差,样本方差,样本标准差
  20. 2016-08-14-京东笔试和面试(Java方向)

热门文章

  1. 金山安全报告:十大病毒危害排行出炉
  2. Android mc怎么和win10联机,大更新我的世界手机版/win10版联机完美互通
  3. 网络安全法学习整理笔记
  4. 计算机专业数据结构试题答案
  5. 立Flag 学习Ng - 1
  6. 如何用O2OA公文编辑器制作标准的红头文件?
  7. VR是什么,去哪里学习?
  8. msdtc.exe dll劫持
  9. php 连接timesten,timesten常见的一些简单问题
  10. CImageList-CBitmap-Usage