当前位置: 首页 > news >正文

专业做网站较好的公司北京效果好的网站推广

专业做网站较好的公司,北京效果好的网站推广,石家庄免费网站建设,无锡万度网站建设📖封装加载弹框 ✅1. 构造LoadingDialog✅2. 调用LoadingDialog 效果: ✅1. 构造LoadingDialog 构造LoadingDialog类涉及到设计模式中的建造者模式,进行链式调用,注重的是构建的过程,设置需要的属性。 步骤一&#x…

📖封装加载弹框

    • ✅1. 构造LoadingDialog
    • ✅2. 调用LoadingDialog

效果:

111

✅1. 构造LoadingDialog

构造LoadingDialog类涉及到设计模式中的建造者模式,进行链式调用,注重的是构建的过程,设置需要的属性。

步骤一:在utils包下创建LoadingDialog

import android.app.Dialog;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;public class LoadingDialog extends Dialog {public LoadingDialog(Context context, int themeResId) {super(context, themeResId);}public static class Builder {private Context context;//上下文private String message;//提示信息private boolean isShowMessage = true;//是否显示提示信息private boolean isCancelable = false;//返回键是否可以取消private boolean isCancelOutside = false;//点击外部是否可以取消//构造方法传入上下文public Builder(Context context) {this.context = context;}//设置提示信息public Builder setMessage(String message) {this.message = message;return this;}//设置是否显示提示信息public Builder setShowMessage(boolean isShowMessage) {this.isShowMessage = isShowMessage;return this;}//设置是否可以按返回键取消public Builder setCancelable(boolean isCancelable) {this.isCancelable = isCancelable;return this;}//设置是否可以取消public Builder setCancelOutside(boolean isCancelOutside) {this.isCancelOutside = isCancelOutside;return this;}//创建LoadingDialog对象public LoadingDialog create() {LayoutInflater inflater = LayoutInflater.from(context);View view = inflater.inflate(R.layout.dialog_loading, null);LoadingDialog loadingDailog = new LoadingDialog(context, R.style.MyProgressDialog);TextView msgText = (TextView) view.findViewById(R.id.messageTextView);if (isShowMessage) {msgText.setText(message);} else {msgText.setVisibility(View.GONE);}loadingDailog.setContentView(view);loadingDailog.setCancelable(isCancelable);loadingDailog.setCanceledOnTouchOutside(isCancelOutside);return loadingDailog;}}
}

步骤二:在layout文件下添加组件:dialog_loading.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="match_parent"android:layout_height="match_parent"android:gravity="center"><!--白色:<color name="white">#ffffffff</color>--><LinearLayoutandroid:layout_width="140dp"android:layout_height="100dp"android:gravity="center"android:orientation="vertical"android:background="@drawable/shape_dialog_redius_gray"><ProgressBarandroid:id="@+id/progressBar"android:layout_width="40dp"android:layout_height="40dp"android:layout_centerHorizontal="true"android:layout_centerVertical="true"android:indeterminate="true"android:indeterminateTint="@android:color/white" /><TextViewandroid:id="@+id/messageTextView"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_below="@id/progressBar"android:layout_centerHorizontal="true"android:layout_marginTop="16dp"android:textColor="@android:color/white"android:textSize="16sp" /></LinearLayout></RelativeLayout>

步骤三:在drawable文件下添加shape:shape_dialog_redius_gray.xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" ><!--黑色半透明:<color name="black_transparent">#98000000</color>--><solid android:color="@color/black_transparent" /><corners android:radius="5dp" />
</shape>

步骤四:在 values 文件下的themes.xml下添加如下主题

	<!--弹框加载样式--><!--透明色:<color name="transparent">#00000000</color>--><style name="MyProgressDialog" parent="Theme.AppCompat.Dialog"><item name="android:windowBackground">@android:color/transparent</item><!--背景透明--><item name="android:windowIsFloating">true</item><!--是否浮动--><item name="android:backgroundDimEnabled">false</item><!--对话框背后的内容是否被暗淡--><item name="android:windowContentOverlay">@null</item><!--设置窗口的内容覆盖物--><item name="android:statusBarColor">@null</item><!--状态栏背景色--></style>

✅2. 调用LoadingDialog

在点击事件或者发生http请求时显示弹框,请求结束后关闭显示即可,下面是使用1秒延时来模拟发送请求

private Handler mHandler = new Handler();//全局定义send.setOnClickListener(new View.OnClickListener() {@Overridepublic void onClick(View view) {//加载弹窗LoadingDialog loadingDialog = new LoadingDialog.Builder(getActivity()).setMessage("加载中...").setCancelable(true)//返回键是否可关闭.setCancelOutside(false)//点击弹框外是否可关闭.create();//显示loadingDialog.show();//模拟异步发送请求后关闭加载弹窗mHandler.postDelayed(new Runnable() {@Overridepublic void run() {//关闭显示loadingDialog.dismiss();}}, 1000);}});
http://www.ds6.com.cn/news/12514.html

相关文章:

  • 扬中网站建设要多少钱广告优化
  • 化妆品网站建设报告营销号
  • 设计网站栏目seo 优化 服务
  • 沧州市高速公路建设管理局网站百度学术官网登录入口
  • 中国电信 网站备案win7系统优化大师
  • dogip网站开发金华网站建设
  • 程序员培训班要什么学历无锡百度快照优化排名
  • 郑州同济医院靠谱吗广州优化防控措施
  • 龙口网站制作公司软件推广赚佣金渠道
  • 怎么才能建立网站实时seo排名点击软件
  • 四川建设网和四川省公共资源交易信息网安卓优化大师官方下载
  • 公司网站被黑有不良信息 做笔录广告联盟平台挂机赚钱
  • 小程序网站开发公司域名查询 ip
  • 做视频解析网站香港头条新闻
  • 西安高端网站建设首选百度竞价开户3000
  • 手机网易网自动app优化最新版
  • 扫描购物网站建设北京高端网站建设
  • 安阳做网站的费用seo网站关键词优化怎么做
  • 廊坊哪里有做网站的如何自己制作网站
  • win2008 建立网站关键词查询工具
  • 网站做轮播图的意义图片识别搜索引擎
  • dw旅游网站模板下载百度官网首页下载
  • 大庆今天最新公告北京seo优化多少钱
  • 做数学题挣钱的网站seo软件优化工具软件
  • 做投融资平台的网站都有哪些?手机广告推广软件
  • 做淘宝优惠券网站要多少钱互联网营销师考证多少钱
  • 做外贸家纺资料网站windows优化大师卸载
  • 关于网站建设外文文献百度搜索推广方法
  • 邢台网站建设最新报价seo整站优化方案
  • web2py做的网站免费软文发布平台有哪些