位置: 编程技术 - 正文

AlertDialog自定义布局(自定义dialogfragment)

编辑:rootadmin

推荐整理分享AlertDialog自定义布局(自定义dialogfragment),希望有所帮助,仅作参考,欢迎阅读内容。

文章相关热门搜索词:自定义dialogfragment,alertdialog自定义输入,alertdialog自定义view,自定义dialogfragment,自定义alert弹出框,alertdialog自定义输入,alertdialog自定义输入,alertdialog自定义输入,内容如对您有帮助,希望把文章链接给更多的朋友!

AlertDialog自定义布局

activity调用

private void showAlertDialog() {final AlertDialogUtil dialog = new AlertDialogUtil(this, false, null); // false代表必须点击"确定"其它不可以点击不消失,true点击其它也消失 dialog.setMessage("您尚未登录"); dialog.setBtnPositiveValue("确定"); dialog.setPositiveClickListener(new OnClickListener() { @Override public void onClick(View arg0) { dialog.dismiss(); } }); dialog.setBtnNegativeValue("取消"); dialog.setNegativeClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub } });

dialog.show();

}

AlertDialog自定义布局(自定义dialogfragment)

AlertDialogUtil工具类

public class AlertDialogUtil extends AlertDialog { private Button btnPositive, btnNegative; private TextView tvMessage; private String message; private String btnPositiveValue, btnNegativeValue; private View.OnClickListener positiveListener, negativeListener; public AlertDialogUtil(Context context, boolean cancelable, OnCancelListener cancelListener) { super(context, cancelable, cancelListener); } @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.dialog_confirm); initView(); } public void setMessage(String message) { this.message = message; } public void setBtnPositiveValue(String val) { this.btnPositiveValue = val; } public void setPositiveClickListener(View.OnClickListener listener) { this.positiveListener = listener; } public void setBtnNegativeValue(String val) { this.btnNegativeValue = val; } public void setNegativeClickListener(View.OnClickListener listener) { this.negativeListener = listener; } private void initView() { // 布局 你可以写你想要的对话框布局 btnPositive = (Button) findViewById(R.id.btn_alertDialogutil_cancel); btnNegative = (Button) findViewById(R.id.btn_alertDialogutil_confirm); tvMessage = (TextView) findViewById(R.id.textView_title_mydialog); if (isNullEmptyBlank(message)) { tvMessage.setVisibility(View.GONE); } else { this.setCancelable(cancelable); tvMessage.setText(message); } if (!(isNullEmptyBlank(btnPositiveValue))) { btnPositive.setText(btnPositiveValue); this.btnPositive.setOnClickListener(positiveListener); } if (!(isNullEmptyBlank(btnNegativeValue))) { btnNegative.setText(btnNegativeValue); this.btnNegative.setOnClickListener(negativeListener); } } private static boolean isNullEmptyBlank(String str) { if (str == null || "".equals(str) || "".equals(str.trim())) return true; return false; }}

xml布局

<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android=" android:layout_width="dp" android:layout_height="dp" android:layout_gravity="center" android:background="@drawable/feedback_edite_bg" android:orientation="vertical" > <LinearLayout android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" android:gravity="center" > <TextView android:id="@&#;id/textView_title_mydialog" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="@color/color_black" android:textSize="sp" > </TextView> </LinearLayout> <LinearLayout android:id="@&#;id/ll_alertDialogutil" android:layout_width="match_parent" android:layout_height="dp" android:orientation="vertical" android:visibility="gone" > <ImageView android:layout_width="match_parent" android:layout_height="1dp" android:background="@color/color_linear" /> <LinearLayout android:layout_width="match_parent" android:layout_height="dp" android:layout_marginLeft="8dp" android:layout_marginRight="8dp" android:orientation="horizontal" > <Button android:id="@&#;id/btn_alertDialogutil_cancel" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:background="@color/color_transparent" android:textColor="@color/color_blue" android:textSize="sp" android:visibility="gone" /> <ImageView android:id="@&#;id/iv_alertDialogutil" android:layout_width="1dp" android:layout_height="match_parent" android:background="@color/color_linear" android:visibility="gone" /> <Button android:id="@&#;id/btn_alertDialogutil_confirm" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:background="@color/color_transparent" android:textColor="@color/color_blue" android:textSize="sp" android:visibility="gone" /> </LinearLayout> </LinearLayout></LinearLayout>

Android常用工具类(收藏) Android常用工具类主要介绍总结的Android开发中常用的工具类,大部分同样适用于Java。目前包括(HttpUtils、DownloadManagerPro、ShellUtils、PackageUtils、PreferencesUt

android系统自带actionbar总结 android不同的版本引入的actionbar有差异,现总结如下一、在support.v7包中引入布局使用onCreateOptionsMenu方法中的参数:inflateimportandroid.support.v7.app.ActionBarActiv

android最基本的lsitvew实现下拉刷新,上拉加载更多的demo 接着上次来讲,这次来动手写一下listview的下拉刷新功能和上拉加载更多功能。当然google在android4.0以上的API里面的提供了一个可以下拉加载更多的控件

标签: 自定义dialogfragment

本文链接地址:https://www.jiuchutong.com/biancheng/378201.html 转载请保留说明!

上一篇:android javascript 混淆配置。

下一篇:Android常用工具类(收藏)(android工具包)

  • 所得税交错了怎么处理
  • 小规模纳税人能开专票吗
  • 企业所得税怎么算出来
  • 小规模纳税人加油发票可以抵扣吗
  • 营利性幼儿园怎样登记
  • 稳岗补贴属于不征税收入吗
  • 企业当年发放以往年度工资
  • 联合体项目工程款如何拨付
  • 待抵扣进项税额是什么意思
  • 预缴企业所得税分录
  • 上月发票错误退回怎么做账
  • 增值税零申报触发附加税零申报
  • 可以不用附原始凭证的记账凭证是
  • 企业对于无法收回的应收账款
  • 分配的股息 要交所得税吗
  • 同一个客户有应收也有应付怎么办
  • 一般纳税人增值税申报操作流程
  • 办公室租金相关法规
  • 出口退税银行账户备案
  • 代扣代缴增值税纳税义务发生时间
  • 核定征收的小型微利企业
  • 销售土地使用权的增值税税率
  • 公司为员工承担房租
  • 房产代理公司收客户钱违法
  • 生产车间广告牌设计图片
  • 工程预收款账务处理
  • 跨年度取得发票会计分录
  • 销售使用过的固定资产3%减按2%
  • 子网掩码和默认网关怎么填
  • 拍卖获得收入个税
  • windows11更新多大
  • html文档怎么写
  • 增值税检查调整科目还在用吗
  • 利润增减幅度
  • 油猴脚本插件官网
  • 金融企业计提贷款利率
  • 亚美尼亚格加尔德修道院
  • yii2框架的优缺点
  • 万字短文
  • 公司法人和股东哪个承担的责任大
  • 商业银行流动性风险监管指标
  • react.strictmode
  • thinkphp6.0完全开发手册
  • 网上报税流程演示2019
  • 企业利润分配的账务处理
  • 汇兑损益是资产类科目
  • 汽车车票增值税税率
  • 分批发货分批付款
  • 不抵扣勾选有什么风险
  • 一般整形医院的药在哪进货
  • MySQL读写分离企业方案
  • 一个分组名称
  • 以前年度损益调整账务处理分录
  • 出口销售确认书的条款
  • 内含增长率的推导
  • 公司账户可以转个人支付宝吗
  • 服务业收入的会计分录
  • mysql 5.6.26 winx64安装配置图文教程(一)
  • mysql 5.7.11 winx64.zip安装配置方法图文教程
  • 复制糸统
  • tcpsyncookies
  • mac系统删除系统软件
  • windows8怎么查看所有程序
  • 更加有效率
  • inodecmn.exe
  • 360修复漏洞补丁一直下载
  • node stream原理
  • 高级控件动态数据加载过程有哪些
  • unity集训
  • js怎么用jquery
  • javascript entries
  • js表单生成器动手实践
  • 传智播客javappt
  • Android Studio cvs 状态颜色
  • android studio如何用安卓手机模拟
  • unity networking
  • layui jquery事件失效
  • 土地招标拍卖挂牌
  • 月收入不足1000
  • 汽车修理厂24小时修理
  • 免责声明:网站部分图片文字素材来源于网络,如有侵权,请及时告知,我们会第一时间删除,谢谢! 邮箱:opceo@qq.com

    鄂ICP备2023003026号

    网站地图: 企业信息 工商信息 财税知识 网络常识 编程技术

    友情链接: 武汉网站建设