直播app系统源码,自定义弹框的简单写法Demo
CustomDialog

package com.sq.module.widgetimport android.app.Dialog
import android.content.Context
import android.content.DialogInterface
import android.view.LayoutInflater
import android.view.View
import android.widget.Button
import android.widget.LinearLayout
import android.widget.TextView
import com.sq.module.R/*** @ClassName ExitDialog* @Description TODO* @Author Kolin Zhao* @Date 2021/6/3 20:45* @Version 1.0*/
class CustomDialog : Dialog {constructor(context: Context?) : super(context!!)constructor(context: Context?, theme: Int) : super(context!!, theme)class Builder(private val context: Context) {var content: String? = nullprivate var positiveButtonClickListener: DialogInterface.OnClickListener? = nullprivate var negativeButtonClickListener: DialogInterface.OnClickListener? = nullfun setContent(content: String): Builder {this.content = contentreturn this}fun setPositiveButton(listener: DialogInterface.OnClickListener): Builder {this.positiveButtonClickListener = listenerreturn this}fun setNegativeButton(listener: DialogInterface.OnClickListener): Builder {this.negativeButtonClickListener = listenerreturn this}fun create(): CustomDialog {val layoutInflater = context.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater//为自定义弹框设置主题val customDialog = CustomDialog(context, R.style.CustomDialog)val view = layoutInflater.inflate(R.layout.dialog_exit, null)customDialog.addContentView(view, LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT,LinearLayout.LayoutParams.WRAP_CONTENT))//设置弹框内容content?.let {(view.findViewById(R.id.dialog_content) as TextView).text = it}//设置弹框按钮positiveButtonClickListener?.let {(view.findViewById(R.id.dialog_sure) as Button).setOnClickListener {positiveButtonClickListener!!.onClick(customDialog, DialogInterface.BUTTON_POSITIVE)}} ?: run {(view.findViewById(R.id.dialog_sure) as Button).visibility = View.GONE}negativeButtonClickListener?.let {(view.findViewById(R.id.dialog_cancel) as Button).setOnClickListener {negativeButtonClickListener!!.onClick(customDialog, DialogInterface.BUTTON_NEGATIVE)}} ?: run {(view.findViewById(R.id.dialog_cancel) as Button).visibility = View.GONE}customDialog.setContentView(view)return customDialog}}
}

直播app系统源码功能调用

val builder = CustomDialog.Builder(this)
builder.setPositiveButton(DialogInterface.OnClickListener { dialogInterface, _ ->dialogInterface.dismiss()//具体逻辑
})
builder.setNegativeButton(DialogInterface.OnClickListener { dialogInterface, _ ->dialogInterface.dismiss()//具体逻辑
})
builder.create().show()

Layout
dialog_exit.xml

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout 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"android:background="@color/transparent"><LinearLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"android:layout_gravity="center"android:layout_margin="@dimen/marginDialog"android:background="@drawable/champer_form"android:orientation="vertical"android:padding="20dp"><TextViewandroid:id="@+id/dialog_content"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_marginVertical="36dp"android:text="确定要退出账号?"tools:ignore="HardcodedText"android:textColor="@color/ThemeDarkPurple"android:textSize="@dimen/title"android:layout_gravity="center"/><LinearLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"android:orientation="horizontal"><Buttonandroid:id="@+id/dialog_cancel"android:layout_width="0dp"android:layout_height="wrap_content"android:layout_marginEnd="6dp"android:layout_weight="1"android:background="@drawable/exit_cancel"android:text="取 消"android:textColor="@color/ThemeBlue"android:textSize="20sp"tools:ignore="HardcodedText" /><Buttonandroid:id="@+id/dialog_sure"android:layout_width="0dp"android:layout_height="wrap_content"android:layout_weight="1"android:background="@drawable/exit_sure"android:text="确定"android:textColor="@color/white"android:textSize="20sp"tools:ignore="HardcodedText"android:layout_marginStart="6dp"/></LinearLayout></LinearLayout></FrameLayout>

champer_form.xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"><solid android:color="@color/white"/><corners android:radius="6dp"/>
</shape>

styles.xml

<!--退出自定义弹框-->
<style name="CustomDialog" parent="Theme.AppCompat.Dialog"><item name="android:background">@color/transparent</item><item name="android:windowBackground">@color/transparent</item><item name="windowNoTitle">true</item><item name="android:windowIsFloating">true</item>
</style>

以上就是 直播app系统源码,自定义弹框的简单写法Demo,更多内容欢迎关注之后的文章

直播app系统源码,自定义弹框的简单写法Demo相关推荐

  1. (H5+安卓+ios)直播app系统源码,直播商城带货源码,方维直播app系统,直播短视频源码

    商品介绍 (H5+安卓+ios)直播app系统源码,直播商城带货源码,方维直播app系统,直播短视频源码,本系统有三个版本:带商城直播系统,带H5直播系统,和一般的直播短视频系统,默认带H5版本系统 ...

  2. 直播app系统源码通过CSS液体实现加载动画

    直播app系统源码通过CSS液体实现加载动画 首先我们要让元素能够旋转起来,可以使用transform中的rotate进行2D的360deg旋转. 紧接着我们可以通过CSS变量(–开头的形式)结合an ...

  3. 在直播APP系统源码中基于腾讯视频云SDK制作简易版直播回放播放器

    在直播App系统中,当主播结束之后,我们需要使用播放器观看直播的一些回放片段,在观看回放的过程中,我们会使用到开始,暂停,控制播放位置,进度监听,全屏等功能,然而腾讯点播并没有提供这些简单的控制功能, ...

  4. 直播短视频带货完美运营APP源码 购物直播交友系统源码

    介绍: 别人互换得来的,没有具体搭建研究,源码附带安卓跟苹果APP源码,没有教程跟安装文档,没技术得就别看了无售后,需要自行研究,大概看了下好像是云豹二开得版本. 软件简介介绍: 直播带货APP系统源 ...

  5. 直播商城系统源码,播放器aliPlayer自定义清晰度切换

    直播商城系统源码,播放器aliPlayer自定义清晰度切换 <!DOCTYPE html> <html><head><meta charset="u ...

  6. 直播网站程序源码,搜索框实现快速搜索功能

    直播网站程序源码,搜索框实现快速搜索功能 module.exports = async function (params, context) {const db = context.databasec ...

  7. 新版金色UI萝卜影视APP系统源码+Java原生开发

    正文: 新版金色UI萝卜影视APP系统源码+Java原生开发,当前这个版本,可以说这是目前以来很牛的一款源码,无论是流畅度,还是原生稳定性都是非常稳定的. 环境:Android Studio,纯Jav ...

  8. 开源PHP社区交友APP系统源码/傻瓜式搭建

    开源PHP社区交友APP系统源码/傻瓜式搭建 ☑️ 编号:ym228 ☑️ 品牌:PHP ☑️ 语言:PHP ☑️ 大小:132MB ☑️ 类型:APP系统源码 ☑️ 支持:APP

  9. 物业员工APP系统源码

    物业员工APP系统源码 系统功能介绍 一.报修管理 在线派单抢单: 移动完成整个报修处理流程: 二.移动收费 物业人员移动收费: 支持多种收费方式: 三.巡更巡检 支持社区日常巡查.设备巡检: 自动生 ...

  10. 2021全新改版影视app系统源码(全开源)

    介绍: 必看:批量替换所有源码文件内容,工具百度nodpad++ 将" 完美视界"替换为自己的软件名. cs.xiao18.top替换为自己的后台地址 后端文件上传到网站根目录解压 ...

最新文章

  1. Linux之文本处理
  2. java学习文档_资深程序员带你深入了解JAVA知识点,实战篇,PDF文档
  3. CCNA实验(8) -- PPP HDLC
  4. Java Web编程技术
  5. 队列C++ | 用链表实现队列_2
  6. CSS 相对定位与绝对定位
  7. 微软IE浏览器1月市场份额再创新低 跌至67.6%
  8. c++——CString,string,char*之间的转换
  9. java项目 字典实现,java项目中数据字典的实现
  10. AxureUX 复制Iconfont图标到Axure
  11. SPH(光滑粒子流体动力学)流体模拟实现五:PCISPH
  12. android密度计算器,密度计算器
  13. 机器学习如何影响系统设计:Learned Index Structures浅析
  14. 洛谷P2178 [NOI2015]品酒大会 后缀数组+单调栈
  15. 如何理解 0.1+0.2
  16. Shell小技巧(一百零五)脚本中的空格小结
  17. java springboot mybaits 邮箱注册实现
  18. 正则表达式中 前瞻,后顾,负前瞻,负后顾等整理
  19. echarts数据可视化项目经验积累
  20. 无法启动此程序因为计算机丢失gdiplus,处理系统提示无法启动此程序,因为计算机中丢失gdiplus.dll的方法...

热门文章

  1. 基因结构图的0_TBtools | 只有序列,怎么做基因结构图?
  2. IE图标删不掉,桌面IE删了又有了
  3. gdb打印超长字符串或数组
  4. STM32----PWM脉宽调制信号的输出
  5. 论文阅读>污垢检测:Vision-Based Dirt Detection and Adaptive Tiling Scheme for Selective Area Coverage
  6. IEEE 802.3标准简介以及各分类标准汇总
  7. 前端应届简历应该怎么写?
  8. html绘制波形图,Html5 canvas 绘制心电波形图
  9. 如何下载B站视频(方法持续更新)
  10. 非深圳户口办理《深圳计划生育证明》需要以下几个证件