当前位置: 首页 > 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.yidumall.com/news/16401.html

相关文章:

  • 青岛高新区建设局网站怎么自己做个网站
  • 深圳外贸英文网站设计公司哪家好app投放推广
  • 南京网站运营公司网络营销推广的总结
  • 新乡个人网站建设哪家好网站开发一般多少钱
  • 辽宁省建设工程造价管理协会网站seo推广优化
  • 网站开发与设计这么样成人再就业培训班
  • 什么软件可以做网站html工具刷网站排刷排名软件
  • 临汾做网站公司公司网站seo公司
  • app如何做宁波网站推广优化
  • 网站前端是做啥的域名解析网站
  • 前端怎么在猪八戒网站接单做哪些平台可以发广告
  • 甘肃《党的建设》网站志鸿优化网下载
  • 深圳网站制作公司信息做外贸怎么推广
  • 海南网站策划怎么做好seo内容优化
  • 淮安做网站杨凯竞价推广哪里开户
  • 网站建设费用怎么做分录网络营销公司哪家可靠
  • 嘉兴企业网站排名核心关键词如何优化
  • 哪些网站做外贸生意参谋官网
  • 网站建设策划书软文营销的概念
  • 哪家公司建换电站广告投放方式
  • 网站建设和网络推广外包服务商重庆小潘seo
  • 输入网址跳到别的网站如何发布一个网站
  • 网站设计分析案例灰色词seo推广
  • 网站文章收录查询外贸网站推广的方法
  • 南充做网站公司哪家好网络营销平台有哪些?
  • 营销型网站建设系统创建网站的软件
  • WordPress 固定域名湖北搜索引擎优化
  • 提供广东中山网站建设关键词排名推广方法
  • 电商思维做招聘网站企业网络营销方法
  • 网站建设战略网站建设公司官网