本文实例为大家分享了Android实现信息弹出框的具体代码,供大家参考,具体内容如下

layout下的dialog_common_layout.xml

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:background="@drawable/bg_round_white"

android:focusable="true"

android:focusableInTouchMode="true"

android:orientation="vertical">

android:id="@+id/title"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:background="@drawable/bg_top_round_left_right_blue"

android:focusable="true"

android:focusableInTouchMode="true"

android:gravity="center_horizontal"

android:padding="12dp"

android:text="@string/tip"

android:textColor="@color/white"

android:textSize="16sp" />

android:layout_width="match_parent"

android:layout_height="match_parent"

android:layout_margin="2dp"

android:baselineAligned="false"

android:orientation="vertical"

android:paddingStart="10dp"

android:paddingEnd="10dp">

android:layout_width="match_parent"

android:layout_height="match_parent"

android:layout_weight="1"

android:orientation="horizontal">

android:id="@+id/ZCMC2"

style="@style/DialogView"

android:layout_width="150dp"

android:layout_height="wrap_content"

android:layout_marginStart="@dimen/re_2_half_gap"

android:text="@string/ZCMC"

android:textColor="#A2A2A8" />

android:id="@+id/ZCMC1"

style="@style/DialogView"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:text="@string/ZCMC" />

android:layout_width="match_parent"

android:layout_height="match_parent"

android:layout_weight="1"

android:orientation="horizontal">

android:id="@+id/FLMC2"

style="@style/DialogView"

android:layout_width="150dp"

android:layout_height="wrap_content"

android:layout_marginStart="@dimen/re_2_half_gap"

android:text="@string/FLMC"

android:textColor="#A2A2A8" />

android:id="@+id/FLMC1"

style="@style/DialogView"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:text="@string/FLMC" />

android:layout_width="match_parent"

android:layout_height="match_parent"

android:layout_margin="2dp"

android:baselineAligned="false"

android:orientation="vertical"

android:paddingStart="10dp"

android:paddingEnd="10dp">

android:layout_width="match_parent"

android:layout_height="match_parent"

android:layout_weight="0.5"

android:orientation="horizontal">

android:id="@+id/SBPP2"

style="@style/DialogView"

android:layout_width="150dp"

android:layout_height="wrap_content"

android:layout_marginStart="@dimen/re_2_half_gap"

android:text="@string/SBPP"

android:textColor="#A2A2A8" />

android:id="@+id/SBPP1"

style="@style/DialogView"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:text="@string/SBPP" />

android:layout_width="match_parent"

android:layout_height="match_parent"

android:layout_weight="0.5"

android:orientation="horizontal">

android:id="@+id/XH2"

style="@style/DialogView"

android:layout_width="150dp"

android:layout_height="wrap_content"

android:layout_marginStart="@dimen/re_2_half_gap"

android:text="@string/XH"

android:textColor="#A2A2A8" />

android:id="@+id/XH1"

style="@style/DialogView"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:layout_marginStart="@dimen/re_2_half_gap"

android:text="@string/XH" />

android:layout_width="match_parent"

android:layout_height="match_parent"

android:layout_margin="2dp"

android:baselineAligned="false"

android:orientation="vertical"

android:paddingStart="10dp"

android:paddingEnd="10dp">

android:layout_width="match_parent"

android:layout_height="match_parent"

android:layout_weight="1"

android:orientation="horizontal">

android:id="@+id/DJ3"

style="@style/DialogView"

android:layout_width="150dp"

android:layout_height="wrap_content"

android:layout_marginStart="@dimen/re_2_half_gap"

android:text="@string/DJ"

android:textColor="#A2A2A8" />

android:id="@+id/DJ1"

style="@style/DialogView"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:text="@string/DJ" />

android:layout_width="match_parent"

android:layout_height="match_parent"

android:layout_weight="1"

android:orientation="horizontal">

android:id="@+id/GZRQ2"

style="@style/DialogView"

android:layout_width="150dp"

android:layout_height="wrap_content"

android:layout_marginStart="@dimen/re_2_half_gap"

android:text="@string/GZRQ"

android:textColor="#A2A2A8" />

android:id="@+id/GZRQ1"

style="@style/DialogView"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:text="@string/GZRQ" />

android:layout_width="match_parent"

android:layout_height="1dp"

android:layout_marginTop="2dp"

android:background="@color/blue_touch_user" />

android:id="@+id/buttonLine"

android:layout_width="match_parent"

android:layout_height="50dp"

android:orientation="horizontal">

android:id="@+id/cancel"

android:layout_width="match_parent"

android:layout_height="match_parent"

android:layout_weight="1.0"

android:background="@drawable/bg_round_left_white"

android:gravity="center"

android:selectAllOnFocus="false"

android:text="@string/cancel"

android:textColor="@color/blue_touch_user"

android:textSize="14sp" />

android:layout_width="1dp"

android:layout_height="match_parent"

android:background="@color/blue_touch_user" />

android:id="@+id/submit"

android:layout_width="match_parent"

android:layout_height="match_parent"

android:layout_weight="1.0"

android:background="@drawable/bg_round_right_white"

android:gravity="center"

android:text="@string/ruku"

android:textColor="@color/blue_user"

android:textSize="14sp" />

android:id="@+id/buttonLine2"

android:layout_width="match_parent"

android:layout_height="50dp"

android:orientation="horizontal">

android:id="@+id/cancel2"

android:layout_width="match_parent"

android:layout_height="match_parent"

android:background="@drawable/bg_round_left_right_white"

android:gravity="center"

android:selectAllOnFocus="false"

android:text="@string/close"

android:textColor="@color/blue_touch_user"

android:textSize="14sp" />

CommomDialog.java

public class CommomDialog extends Dialog implements View.OnClickListener{

private Context mContext;

private PageData content;

private OnCloseListener listener;

private String positiveName;

private String negativeName;

private String title;

public CommomDialog(Context context) {

super(context);

this.mContext = context;

}

public CommomDialog(Context context, int themeResId, PageData content) {

super(context, themeResId);

this.mContext = context;

this.content = content;

}

public CommomDialog(Context context, int themeResId, PageData content, OnCloseListener listener) {

super(context, themeResId);

this.mContext = context;

this.content = content;

this.listener = listener;

}

protected CommomDialog(Context context, boolean cancelable, OnCancelListener cancelListener) {

super(context, cancelable, cancelListener);

this.mContext = context;

}

public CommomDialog setTitle(String title){

this.title = title;

return this;

}

public CommomDialog setPositiveButton(String name){

this.positiveName = name;

return this;

}

public CommomDialog setNegativeButton(String name){

this.negativeName = name;

return this;

}

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.dialog_common_layout);

setCanceledOnTouchOutside(false);

initView();

}

private void initView(){

TextView ZCMC = (TextView) findViewById(R.id.ZCMC1);

TextView GZRQ = (TextView) findViewById(R.id.GZRQ1);

TextView DJ = (TextView) findViewById(R.id.DJ1);

TextView XH = (TextView) findViewById(R.id.XH1);

TextView SBPP = (TextView) findViewById(R.id.SBPP1);

TextView FLMC = (TextView) findViewById(R.id.FLMC1);

LinearLayout buttonLine=(LinearLayout) findViewById(R.id.buttonLine);

LinearLayout buttonLine2=(LinearLayout) findViewById(R.id.buttonLine2);

TextView titleTxt = (TextView) findViewById(R.id.title);

TextView submitTxt = (TextView) findViewById(R.id.submit);

submitTxt.setOnClickListener(this);

TextView cancelTxt = (TextView) findViewById(R.id.cancel);

cancelTxt.setOnClickListener(this);

TextView cancelTxt2 = (TextView) findViewById(R.id.cancel2);

cancelTxt2.setOnClickListener(this);

ZCMC.setText(content.getString("ZCMC").trim());

GZRQ.setText(content.getString("GZRQ").trim());

DJ.setText(content.getString("DJ").trim());

XH.setText(content.getString("XH").trim());

SBPP.setText(content.getString("SBPP").trim());

FLMC.setText(content.getString("FLMC").trim());

if(!TextUtils.isEmpty(positiveName)){

submitTxt.setText(positiveName);

}

if(!TextUtils.isEmpty(negativeName)){

cancelTxt.setText(negativeName);

}

if(!TextUtils.isEmpty(negativeName)){

cancelTxt2.setText(negativeName);

}

if(!TextUtils.isEmpty(title)){

titleTxt.setText(title);

}

System.out.println(content.getString("JYZT"));

if(!TextUtils.isEmpty(positiveName)&&positiveName.equals("出库")){

if(!content.getString("JYZT").equals("1.0")){

buttonLine2.setVisibility(View.GONE);

buttonLine.setVisibility(View.VISIBLE);

}else{

buttonLine.setVisibility(View.GONE);

buttonLine2.setVisibility(View.VISIBLE);

}

}else if(!TextUtils.isEmpty(positiveName)&&positiveName.equals("入库")){

//归还资产入库

if(!content.getString("JYZT").equals("1.0")){

buttonLine.setVisibility(View.GONE);

buttonLine2.setVisibility(View.VISIBLE);

}else{

buttonLine2.setVisibility(View.GONE);

buttonLine.setVisibility(View.VISIBLE);

}

}else{

//新增资产入库

buttonLine.setVisibility(View.VISIBLE);

buttonLine2.setVisibility(View.GONE);

}

}

@Override

public void onClick(View v) {

switch (v.getId()){

case R.id.cancel2:

if(listener != null){

listener.onClick(this, false);

}

this.dismiss();

break;

case R.id.cancel:

if(listener != null){

listener.onClick(this, false);

}

this.dismiss();

break;

case R.id.submit:

if(listener != null){

listener.onClick(this, true);

}

break;

}

}

public interface OnCloseListener{

void onClick(Dialog dialog, boolean confirm);

}

}

drawable下bg_top_round_left_right_blue.xml

bg_round_left_white.xml

bg_round_right_white.xml

bg_round_left_right_white.xml

styles.xml

@null

true

false

true

@android:color/transparent

true

使用

//弹出框 确认按钮

CommomDialog commomDialog = new CommomDialog(HjtzActivity.this, R.style.dialog, gwcInfo, new CommomDialog.OnCloseListener() {

@Override

public void onClick(Dialog dialog, boolean confirm) {

dialogClose=true;

if(confirm){

PageData rkParam=new PageData();

rkParam.put("HJH",hjbh.getText().toString());

rkParam.put("DAH",DAH);

rkParam.put("CFDD",CFDD);

rkParam.put("WAREID",gwcInfo.getString("WAREID"));

mDialog2 = LoadDialogUtils.createLoadingDialog(HjtzActivity.this, "loading...");

addSubscription(httpApi.updateHjhInfo(rkParam),new SubscriberCallBack(new ApiCallBack() {

@Override

public void onSuccess(ResponseWrapper resp) {

if(resp.getCode()!=0){

showMsg("请求失败");

}else{

showMsg("调整成功!");

}

}

@Override

public void onFailure(int code, String msg) {

showMsg(msg);

System.out.println(msg);

}

@Override

public void onCompoleted() {

LoadDialogUtils.closeDialog(mDialog2);

}

}));

}

dialog.dismiss();

}

});

dialogClose=false;

commomDialog.setTitle("货架调整").setPositiveButton("调整").show();

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持脚本之家。

c语言获取安卓弹窗,Android实现信息弹出框相关推荐

  1. android的底部弹出框炫酷的样式,Android自定义底部弹出框ButtomDialog

    本文实例为大家分享了Android自定义底部弹出框的具体代码,供大家参考,具体内容如下 先看看效果和你要的是否一样 一 .先来配置自定义控件需要的资源 1.在res文件夹下创建一个anim文件夹并创建 ...

  2. android弹出框自定义按钮,安卓(kotlin)自定义弹出框

    在安卓开发中,我们经常会遇到这种情况,就是可爱的UI们设计了一套属于我们自己风格的弹出框,为了彰显我们自己的风格,使用自动的dialog当然满足不了我们的需求,所以还是得这基础上写出我们自己的提示框, ...

  3. android实现底部弹出框与软键盘冲突(全面屏虚拟键适配)

    普通的底部弹出框大家都可以很熟练的使用了,无非是一个diaolog的事情,但是当dialog中含有输入框之后,软键盘与dialog的冲突可以说是十分坑了...更别说加上底部虚拟键了,这么一个小功能磨得 ...

  4. Android自定义退出弹出框

    在应用中不是很常见自定义的退出弹出框,游戏中我们经常能看到.下面就看下是怎么实现的,首先我们定义一个方法,当用户点击退出的时候调用这个方法. 1 private void dialog() { 2 f ...

  5. vue点击input框出现弹窗_vue组件实现弹出框点击显示隐藏效果

    本文实例为大家分享了vue实现弹出框点击显示隐藏的具体代码,供大家参考,具体内容如下 效果如下图 由于我的更改密码弹出框是一个组件引用的,所以在一开始是隐藏的,这就需要在当前的页面上对弹出框组件设置v ...

  6. android 朋友圈弹出框,Android popupwidown 实现朋友圈评论弹窗显示在软键盘上面

    布局: android:layout_width="match_parent" android:layout_height="wrap_content" and ...

  7. android js 弹窗,Android WebView 不能弹出alert的对话框

    加载WebView弹框没有弹出来,百思不得其解,后来发现是Android WebView会阻止alert对话框弹出.如何才能让它不阻止呢,解决方法如下: mWebview.setWebChromeCl ...

  8. android关闭系统弹窗,Android 禁止 EditText 弹出软件盘

    禁止弹出 21版本后有方法mEditText.setShowSoftInputOnFocus(false);可以设置不显示 21版本之前采用反射的方式获取方法名,然后调用 public void hi ...

  9. android 自定义spnner弹出框,PopupWindow,ListView实现自定义Spinner

    最终的效果图,点击+86弹出popup 这里写图片描述 PupupWindow的布局文件 为一个ListView 作为pupup的主体内容 android:orientation="vert ...

最新文章

  1. gen_caltab自治标定板
  2. 工作中收集JSCRIPT代码之(下拉框篇)
  3. Linxu服务器文件双向同步 rsync+sersync 详细讲解
  4. 接口测试工具--apipost如何取消json参数中转义字符
  5. npm安装任何包都报错的解决办法
  6. 女生不能学理科?python+数据可视化分析15万考生的成绩,刷新了我的认知
  7. 集成学习lgb库调参的粒子群方法
  8. 团队天梯赛L1-001
  9. maya中的桥接命令
  10. cc1: all warnings being treated as errors
  11. C语言程序设计三大基本结构之顺序结构
  12. java棋盘最短路径障碍物_(Eucledian最短路径)检测平面中障碍物的角落
  13. Vue3+file-saver+xlsx 实现 excel 导出
  14. HTML_html自动播放音乐
  15. Springboot 搭建oss文件上传服务器
  16. FileReader和FileOutputStream
  17. 微信公众号怎么发PDF文件
  18. Windows无法安装驱动原因总结
  19. MATLAB的数列与极限运算
  20. BugkuCTF~Misc~WriteUp

热门文章

  1. 关于java多态中覆盖的理解
  2. Linux 下的dd命令使用详解(摘录)
  3. NYOJ 737---石子归并(GarsiaWachs算法)
  4. W3School-CSS 表格实例
  5. CodeSign error: code signing is required for product type Application in SDK iOS
  6. matlab无穷积分求解_从零开始的matlab学习笔记——(8)积分
  7. jvm 参数_6个重要的JVM性能参数
  8. js 字符串截取_【js】让你一次性搞清楚slice,substr,substring字符串截取函数
  9. CSS设置文本字体居中
  10. n阶完全图边和顶点关系。_正N边型的完全图被分割成几个多边形