package com.wangj.baselibrary.util;
import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import com.wangj.baselibrary.R;
/**
* 通用对话框工具类
* Created by WangJie on 2017-04-15.
*/
public class DialogUtil {
private static Dialog dialog; // 只使用一个Dialog实例
private static View hintView;
private static View decideView;
/**
* 提示框(无标题,一个确认键)
*
* @param context 上下文
* @param msgStr 提示内容文字
* @param exitCurrentActivity 点击确认按钮是否退出当前Activity
*/
public static void showHintDialog(Context context,
String msgStr,
boolean exitCurrentActivity) {
hintView = prepareHintView(context, false, null, msgStr, "确定", exitCurrentActivity);
dialog = createDialog(context, hintView, false);
dialog.show();
}
/**
* 提示框(无标题,一个确认键)
*
* @param context 上下文
* @param msgStrId 提示内容文字资源ID
* @param exitCurrentActivity 点击确认按钮是否退出当前Activity
*/
public static void showHintDialog(Context context,
int msgStrId,
boolean exitCurrentActivity) {
showHintDialog(context, context.getResources().getString(msgStrId), exitCurrentActivity);
}
/**
* 提示框(无标题,一个确认键)
*
* @param context 上下文
* @param msgStr 提示内容文字
* @param listener 确认按钮响应事件
*/
public static void showHintDialog(Context context,
String msgStr,
View.OnClickListener listener) {
showHintDialog(context, false, null, msgStr, "确定", listener);
}
/**
* 提示框(无标题,一个确认键)
*
* @param context 上下文
* @param msgStrId 提示内容文字资源ID
* @param listener 确认按钮响应事件
*/
public static void showHintDialog(Context context,
int msgStrId,
View.OnClickListener listener) {
showHintDialog(context, context.getResources().getString(msgStrId), listener);
}
/**
* 提示框(带标题,一个确认按钮)
*
* @param context 上下文
* @param titleStr 标题文字
* @param msgStr 内容显示文字
* @param exitCurrentActivity 点击确认按钮是否退出当前Activity
*/
public static void showHintDialogWithTitle(Context context,
String titleStr,
String msgStr,
boolean exitCurrentActivity) {
hintView = prepareHintView(context, true, titleStr, msgStr, "确定",
exitCurrentActivity);
dialog = createDialog(context, hintView, false);
dialog.show();
}
/**
* 提示框(带标题,一个确认按钮)
*
* @param context 上下文
* @param titleStrId 标题文字资源ID
* @param msgStrId 内容显示文字资源ID
* @param exitCurrentActivity 点击确认按钮是否退出当前Activity
*/
public static void showHintDialogWithTitle(Context context,
int titleStrId,
int msgStrId,
boolean exitCurrentActivity) {
showHintDialogWithTitle(context, context.getResources().getString(titleStrId),
context.getResources().getString(msgStrId), exitCurrentActivity);
}
/**
* 提示框(带标题,一个确认按钮)
*
* @param context 上下文
* @param titleStr 标题文字
* @param msgStr 内容显示文字
* @param listener 点击确认按钮响应事件
*/
public static void showHintDialogWithTitle(Context context,
String titleStr,
String msgStr,
View.OnClickListener listener) {
showHintDialog(context, true, titleStr, msgStr, "确定", listener);
}
/**
* 提示框(带标题,一个确认按钮)
*
* @param context 上下文
* @param titleStrId 标题文字资源ID
* @param msgStrId 内容显示文字资源ID
* @param listener 点击确认按钮响应事件
*/
public static void showHintDialogWithTitle(Context context,
int titleStrId,
int msgStrId,
View.OnClickListener listener) {
showHintDialog(context, true, context.getResources().getString(titleStrId),
context.getResources().getString(msgStrId), "确定", listener);
}
/**
* 提示框(全属性:标题、内容、按钮文字、按钮响应)
*
* @param context 上下文
* @param showTitle 是否显示标题
* @param titleStr 标题文字
* @param msgStr 内容文字
* @param btnStr 按钮文字
* @param listener 按钮响应监听
*/
public static void showHintDialog(Context context,
boolean showTitle,
String titleStr,
String msgStr,
String btnStr,
View.OnClickListener listener) {
hintView = prepareHintView(context, showTitle, titleStr, msgStr, btnStr, listener);
dialog = createDialog(context, hintView, false);
dialog.show();
}
/**
* 准备提示框View(无按钮响应监听)
*/
private static View prepareHintView(final Context context,
boolean showTitle,
String title,
String content,
String btnString,
final boolean exitCurrentActivity) {
hintView = LayoutInflater.from(context).inflate(R.layout.dialog_hint, null);
TextView tvTitle = (TextView) hintView.findViewById(R.id.tv_title);
tvTitle.setText(title);
TextView tvContent = (TextView) hintView.findViewById(R.id.tv_content);
tvContent.setText(content);
Button btnIKnow = (Button) hintView.findViewById(R.id.btn_iknow);
btnIKnow.setText(btnString);
btnIKnow.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
dialog.dismiss();
if (exitCurrentActivity) {
dismissDialog();
((Activity) context).finish();
}
}
});
hintView.findViewById(R.id.tv_title).setVisibility(
showTitle ? View.VISIBLE : View.GONE);
return hintView;
}
/**
* 准备提示框View(带按钮响应监听)
*/
private static View prepareHintView(final Context context,
没有合适的资源?快使用搜索试试~ 我知道了~
Tomcat+MySQL为自己的APP打造服务器(4)完结篇Demo
共124个文件
xml:46个
java:24个
class:12个
5星 · 超过95%的资源 需积分: 31 587 下载量 94 浏览量
2017-05-09
17:28:04
上传
评论 31
收藏 5.07MB ZIP 举报
温馨提示
本代码是【一步一个脚印】Tomcat+MySQL为自己的APP打造服务器(4)完结篇的示例代码,Android+服务端交互代码
资源推荐
资源详情
资源评论
收起资源包目录
Tomcat+MySQL为自己的APP打造服务器(4)完结篇Demo (124个子文件)
gradlew.bat 2KB
LoginServlet.class 4KB
ProductServlet.class 3KB
DES.class 3KB
DatabaseUtil.class 2KB
EncodeFilter.class 2KB
CommonResponse.class 2KB
ParseUtil.class 1KB
CommonRequest.class 1KB
LogUtil.class 492B
EncryptUtil.class 465B
DecryptUtil.class 465B
DBNames.class 399B
.classpath 1KB
org.eclipse.wst.common.component 497B
org.eclipse.wst.jsdt.ui.superType.container 49B
.gitignore 127B
.gitignore 8B
.gitignore 8B
build.gradle 731B
build.gradle 649B
build.gradle 521B
settings.gradle 32B
gradlew 5KB
app.iml 11KB
baselibrary.iml 10KB
bcprov-jdk15on-156.jar 3.29MB
mysql-connector-java-5.1.40-bin.jar 968KB
commons-collections-3.2.1.jar 562KB
commons-beanutils-1.9.3.jar 240KB
commons-lang-2.3.jar 240KB
json-lib-2.4-jdk15.jar 155KB
ezmorph-1.0.6.jar 84KB
commons-logging-1.2.jar 60KB
gradle-wrapper.jar 52KB
DialogUtil.java 15KB
ListActivity.java 4KB
HttpPostTask.java 4KB
LoginServlet.java 4KB
CommonResponse.java 3KB
MainActivity.java 3KB
DES.java 3KB
LogUtil.java 2KB
ProductServlet.java 2KB
CommonRequest.java 2KB
DatabaseUtil.java 2KB
LoadingDialogUtil.java 2KB
BaseActivity.java 2KB
EncodeFilter.java 2KB
TimerThread.java 2KB
CommonResponse.java 1KB
CommonRequest.java 515B
Constant.java 498B
ResponseHandler.java 475B
ParseUtil.java 453B
DecryptUtil.java 299B
EncryptUtil.java 296B
DBNames.java 197B
LogUtil.java 122B
.jsdtscope 567B
MANIFEST.MF 39B
org.eclipse.wst.jsdt.ui.superType.name 6B
ic_launcher.png 10KB
ic_launcher.png 8KB
ic_launcher.png 5KB
ic_launcher.png 3KB
ic_launcher.png 2KB
loading_dialog_2.png 2KB
loading_dialog_3.png 2KB
loading_dialog_1.png 2KB
ic_arrow.png 1KB
org.eclipse.jdt.core.prefs 364B
proguard-rules.pro 667B
proguard-rules.pro 667B
.project 1KB
gradle.properties 747B
local.properties 432B
gradle-wrapper.properties 233B
workspace.xml 224KB
misc.xml 2KB
dialog_decide.xml 2KB
activity_main.xml 2KB
colors.xml 1KB
item_product.xml 1KB
dialog_hint.xml 1KB
support_media_compat_25_0_1.xml 1KB
support_core_utils_25_0_1.xml 1KB
support_fragment_25_0_1.xml 1KB
support_core_ui_25_0_1.xml 1KB
support_compat_25_0_1.xml 1KB
selector_b_radius.xml 1KB
appcompat_v7_25_0_1.xml 1KB
selector_btn_common.xml 1KB
selector_bl_radius.xml 984B
selector_br_radius.xml 952B
dialog_loading.xml 918B
animated_vector_drawable_25_0_1.xml 824B
support_vector_drawable_25_0_1.xml 817B
AndroidManifest.xml 810B
Project_Default.xml 795B
共 124 条
- 1
- 2
衷水木先生
- 粉丝: 1012
- 资源: 12
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- Unity适用于Windows与移动平台双端的轮盘交互式提示菜单
- UE5/UE4超详细教程接入科大讯飞语音唤醒SDK并初始持久监听(10102错误码解决)
- 靠搬运古装剧解说视频,日收益200+,作品原创度90%以上,超详细教程-教程网盘链接提取码下载 .txt
- 2024最强数学建模之美赛攻略.md
- STM32单片机FPGA毕设电路原理论文报告一种机器人寻线控制系统
- STM32单片机FPGA毕设电路原理论文报告一种光电编码器位置检测系统研究与应用
- linux常用命令大全
- ACM题库,分类整理.md
- STM32单片机FPGA毕设电路原理论文报告一种高速折刀运动控制系统的设计与实现
- ZYWIFI0939C循迹、红外避障、遥控综合程序.plg
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
- 3
- 4
前往页