栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 移动开发 > Android

Android 多种简单的弹出框样式设置代码

Android 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Android 多种简单的弹出框样式设置代码

简介

这是一个基于alertDialog和Dialog这两个类封装的多种弹出框样式,其中提供各种简单样式的弹出框使用说明。同时也可自定义弹出框。

项目地址:http://www.github.com/jjdxmashl/jjdxm_dialogui

特性

1.使用链式开发代码简洁明了

2.所有的弹出框样式都在DialogUIUtils这个类中完成,方便查阅方法

3.可以自定义弹出框字体样式

4.简单的类似加载框的样式可以支持两种主题更改默认白色和灰色

截图

 








demo下载

demo apk下载

Download or grab via Maven:


com.dou361.dialogui
jjdxm-dialogui
x.x.x

or Gradle:

compile 'com.dou361.dialogui:jjdxm-dialogui:x.x.x'

历史版本:

compile 'com.dou361.dialogui:jjdxm-dialogui:1.0.1'
compile 'com.dou361.dialogui:jjdxm-dialogui:1.0.0'
jjdxm-dialogui requires at minimum Java 9 or Android 2.3.

架包的打包引用以及冲突解决

代码混淆

根据你的混淆器配置和使用,您可能需要在你的proguard文件内配置以下内容:

-keep class com.dou361.** {
*;
}

AndroidStudio代码混淆注意的问题

快速开始

step1

如果需要使用toast类,采用单例模式的,多次调用toast后只会显示一个,需要初始化DialogUIUtils类,否则会抛异常,使用前初始化即可,代码如下

DialogUIUtils.init(appContext);

step2

如果不需要使用toast类,可以不操作step1,直接使用相对于的弹出框即可。以下分别是部分弹出框的调用代码案例。

自定义弹出框


public static BuildBean showCustomalert(Context context, View contentView)

public static BuildBean showCustomalert(Context context, View contentView, int gravity)

public static BuildBean showCustomalert(Context context, View contentView, int gravity, boolean cancleable, boolean outsideTouchable)

具体使用

View rootView = View.inflate(activity, R.layout.custom_dialog_layout, null);
DialogUIUtils.showCustomalert(this, rootView).show();

弹出toast


public static BuildBean showToastTie(Context context, CharSequence msg) 

public static BuildBean showToastTie(Context context, CharSequence msg, boolean isWhiteBg) 

public static BuildBean showToastTie(Context context, CharSequence msg, boolean cancleable, boolean outsideTouchable, boolean isWhiteBg)

具体使用

DialogUIUtils.showToastTie(this, "加载中...").show();

横向加载框


public static BuildBean showLoadingHorizontal(Context context, CharSequence msg)

public static BuildBean showLoadingHorizontal(Context context, CharSequence msg, boolean isWhiteBg)

public static BuildBean showLoadingHorizontal(Context context, CharSequence msg, boolean cancleable, boolean outsideTouchable, boolean isWhiteBg)

具体使用

DialogUIUtils.showLoadingHorizontal(this, "加载中...").show();

md风格横向加载框


public static BuildBean showMdLoadingHorizontal(Context context, CharSequence msg)

public static BuildBean showMdLoadingHorizontal(Context context, CharSequence msg, boolean isWhiteBg) 

public static BuildBean showMdLoadingHorizontal(Context context, CharSequence msg, boolean cancleable, boolean outsideTouchable, boolean isWhiteBg)

具体使用

DialogUIUtils.showMdLoadingHorizontal(this, "加载中...").show();

竖向加载框


public static BuildBean showLoadingVertical(Context context, CharSequence msg) 

public static BuildBean showLoadingVertical(Context context, CharSequence msg, boolean isWhiteBg) 

public static BuildBean showLoadingVertical(Context context, CharSequence msg, boolean cancleable, boolean outsideTouchable, boolean isWhiteBg)

具体使用

DialogUIUtils.showLoadingVertical(this, "加载中...").show();

md风格竖向加载框


public static BuildBean showMdLoadingVertical(Context context, CharSequence msg)

public static BuildBean showMdLoadingVertical(Context context, CharSequence msg, boolean isWhiteBg)

public static BuildBean showMdLoadingVertical(Context context, CharSequence msg, boolean cancleable, boolean outsideTouchable, boolean isWhiteBg)

具体使用

DialogUIUtils.showMdLoadingVertical(this, "加载中...").show();

md风格弹出框


public static BuildBean showMdalert(Activity activity, CharSequence title, CharSequence msg, DialogUIListener listener)

public static BuildBean showMdalert(Activity activity, CharSequence title, CharSequence msg, boolean cancleable, boolean outsideTouchable, DialogUIListener listener)

具体使用

DialogUIUtils.showMdalert(activity, "标题", "文本内容", new DialogUIListener() {
@Override
public void onPositive() {
}
@Override
public void onNegative() {

}
}).show();

md风格多选框


public static BuildBean showMdMultiChoose(Activity activity, CharSequence title, CharSequence[] words, boolean[] checkedItems, DialogUIListener listener)

public static BuildBean showMdMultiChoose(Activity activity, CharSequence title, CharSequence[] words, boolean[] checkedItems, boolean cancleable, boolean outsideTouchable, DialogUIListener listener)

具体使用

String[] words = new String[]{"1", "2", "3"};
boolean[] choseDefault = new boolean[]{false, false, false};
DialogUIUtils.showMdMultiChoose(activity, "标题", words, choseDefault, new DialogUIListener() {
@Override
public void onPositive() {
}
@Override
public void onNegative() {

}
}).show();

单选框


public static BuildBean showSingleChoose(Activity activity, CharSequence title, int defaultChosen, CharSequence[] words, DialogUIItemListener listener) 

public static BuildBean showSingleChoose(Activity activity, CharSequence title, int defaultChosen, CharSequence[] words, boolean cancleable, boolean outsideTouchable, DialogUIItemListener listener)

具体使用

String[] words2 = new String[]{"1", "2", "3"};
DialogUIUtils.showSingleChoose(activity, "单选", 0, words2, new DialogUIItemListener() {
@Override
public void onItemClick(CharSequence text, int position) {
showToast(text + "--" + position);
}
}).show();

提示弹出框


public static BuildBean showalert(Activity activity, CharSequence title, CharSequence msg, DialogUIListener listener)

public static BuildBean showalert(Activity activity, CharSequence title, CharSequence msg, boolean cancleable, boolean outsideTouchable, DialogUIListener listener)

具体使用

DialogUIUtils.showalert(activity, "标题", "文本内容", new DialogUIListener() {
@Override
public void onPositive() {
}
@Override
public void onNegative() {
}
}).show();

横向弹出框


public static BuildBean showalertHorizontal(Context activity, CharSequence title, CharSequence msg, DialogUIListener listener) 

public static BuildBean showalertHorizontal(Context activity, CharSequence title, CharSequence msg, boolean cancleable, boolean outsideTouchable, DialogUIListener listener)

具体使用

DialogUIUtils.showalertHorizontal(activity, "标题", "文本内容", new DialogUIListener() {
@Override
public void onPositive() {
}
@Override
public void onNegative() {
}
}).show();

竖向弹出框


public static BuildBean showalertVertical(Context activity, CharSequence title, CharSequence msg, DialogUIListener listener)

public static BuildBean showalertVertical(Context activity, CharSequence title, CharSequence msg, boolean cancleable, boolean outsideTouchable, DialogUIListener listener)

具体使用

DialogUIUtils.showalertVertical(activity, "标题", "文本内容", new DialogUIListener() {
@Override
public void onPositive() {
}
@Override
public void onNegative() {
}
}).show();

中间弹出列表


public static BuildBean showCenterSheet(Context context, List words, DialogUIItemListener listener)

public static BuildBean showCenterSheet(Context context, List words, boolean cancleable, boolean outsideTouchable, DialogUIItemListener listener)

具体使用

List strings = new ArrayList<>();
strings.add("1");
strings.add("2");
strings.add("3");
DialogUIUtils.showCenterSheet(activity, strings, new DialogUIItemListener() {
@Override
public void onItemClick(CharSequence text, int position) {
}
@Override
public void onBottomBtnClick() {
}
}).show();

带取消的底部弹出列表


public static BuildBean showBottomSheetAndCancel(Context context, List words, CharSequence bottomTxt, DialogUIItemListener listener)

public static BuildBean showBottomSheetAndCancel(Context context, List words, CharSequence bottomTxt, boolean cancleable, boolean outsideTouchable, DialogUIItemListener listener)

具体使用

List strings = new ArrayList<>();
strings.add("1");
strings.add("2");
strings.add("3");
DialogUIUtils.showBottomSheetAndCancel(activity, strings, "取消", new DialogUIItemListener() {
@Override
public void onItemClick(CharSequence text, int position) {
}
@Override
public void onBottomBtnClick() {
}
}).show();

底部弹出列表


public static BuildBean showBottomSheet(Activity context, List datas, DialogUIItemListener listener)

public static BuildBean showBottomSheet(Activity context, List datas, boolean cancleable, boolean outsideTouchable, DialogUIItemListener listener)

具体使用

List datass = new ArrayList<>();
datass.add(new BottomSheetBean(0, "1"));
datass.add(new BottomSheetBean(0, "2"));
datass.add(new BottomSheetBean(0, "3"));
DialogUIUtils.showBottomSheet(this, datass, new DialogUIItemListener() {
@Override
public void onItemClick(CharSequence text, int position) {
}
}).show();

输入框


public static BuildBean showalertInput(Context context, CharSequence title, CharSequence hint1, CharSequence hint2, CharSequence firstTxt, CharSequence secondTxt, DialogUIListener listener)

public static BuildBean showalertInput(Context context, CharSequence title, CharSequence hint1, CharSequence hint2, CharSequence firstTxt, CharSequence secondTxt, boolean cancleable, boolean outsideTouchable, DialogUIListener listener)

具体使用

DialogUIUtils.showalertInput(activity, "登录", "请输入用户名", "请输入密码", "登录", "取消", new DialogUIListener() {
@Override
public void onPositive() {
}
@Override
public void onNegative() {
}
@Override
public void onGetInput(CharSequence input1, CharSequence input2) {
}
}).show();

md风格竖向底部弹出列表


public static BuildBean showMdBottomSheetVertical(Context context, CharSequence title, List datas, CharSequence bottomTxt, DialogUIItemListener listener)

public static BuildBean showMdBottomSheetVertical(Context context, CharSequence title, List datas, CharSequence bottomTxt, boolean cancleable, boolean outsideTouchable, DialogUIItemListener listener)

具体使用

List datass = new ArrayList<>();
datass.add(new BottomSheetBean(0, "1"));
datass.add(new BottomSheetBean(0, "2"));
datass.add(new BottomSheetBean(0, "3"));
DialogUIUtils.showMdBottomSheetVertical(this, datass, new DialogUIItemListener() {
@Override
public void onItemClick(CharSequence text, int position) {
}
}).show();

md风格横向底部弹出列表


public static BuildBean showMdBottomSheetHorizontal(Context context, CharSequence title, List datas, CharSequence bottomTxt, int columnsNum, DialogUIItemListener listener) 

public static BuildBean showMdBottomSheetHorizontal(Context context, CharSequence title, List datas, CharSequence bottomTxt, int columnsNum, boolean cancleable, boolean outsideTouchable, DialogUIItemListener listener)

具体使用

List datass = new ArrayList<>();
datass.add(new BottomSheetBean(0, "1"));
datass.add(new BottomSheetBean(0, "2"));
datass.add(new BottomSheetBean(0, "3"));
DialogUIUtils.showMdBottomSheetHorizontal(this, datass, new DialogUIItemListener() {
@Override
public void onItemClick(CharSequence text, int position) {
}
}).show();

项目地址:http://www.github.com/jjdxmashl/jjdxm_dialogui

以上所述是小编给大家介绍的Android 多种简单的弹出框样式设置代码,数据库显示空白的完美解决方案(图文教程),希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对考高分网网站的支持!

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/160879.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号