位置: 编程技术 - 正文

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%的税率吗
  • 小规模定期定额申报
  • 分公司背书给总公司
  • 非公司私营企业属于什么类型
  • 长期待摊费用当月减少当月摊销吗
  • 固定资产验收单图片
  • 投资设立民间非经济组织
  • 个税专项附加扣除是什么意思
  • 去年亏损今年第一季度盈利
  • 外资企业税率是多少
  • apple mac 系统
  • 平均应收账款是什么
  • 捐赠支出税前扣除票据
  • 文化事业建设费2023年是否减免了
  • 企业增值税征收范围包括
  • 税务登记后每个月交什么钱
  • system-coredump进程
  • ecap.exe是什么意思
  • 销项冲红可以退税吗?
  • php常用设计模式有哪些
  • 成本类账户期末余额在借方还是贷方
  • 购入固定资产计入应付账款还是其他应付款
  • 开票物流辅助服务怎么搜
  • mongodb快速入门
  • 商品售后回购分录
  • 股东投资款超过实收资本怎么处理
  • 增值税报完了能改么
  • 预收账款挂多久确认收入
  • 财务的原始凭证
  • 综合保税区可以随便进出吗
  • 豆腐是农产品还是工业产品
  • 会计上需要结转的科目
  • 应付账款重分类是什么意思
  • 注册资本没有全额投入,公司银行贷款贷款利息怎么入账
  • 私车公用属于违反什么纪律
  • 以货物抵债的会计分录
  • 工资和社保基数的关系
  • 期初建账库存现金如何填写
  • 电费发票开据后如何入帐?
  • 将税后利润首先用于增加投资
  • 资本公积和盈余公积的用途
  • 生产成本结转到本年利润吗
  • sql server 数学函数
  • win7旗舰版关闭强制签名
  • 苹果电脑截图快捷键
  • linux中使用最多的命令
  • mac 系统查看
  • win7系统无法安装ie8
  • 进程 电脑
  • 微软windows10正版
  • cocos输入框
  • cocos2d-x window实现鼠标移动 键盘事件
  • jquery的鼠标移入事件
  • android 4.2
  • perl匹配空行
  • jquery教程w3school
  • android定时器的使用
  • div+css与xhtml+css分别是什么意思?
  • django图片加载不出来
  • Node.js中的核心模块包括哪些内容?
  • python 中 range
  • shell脚本逐条执行
  • unity5.x游戏开发指南
  • javascriptz
  • python+Django+apache的配置方法详解
  • 2020年砂石
  • 马云交了多少税费
  • 江苏省教师增量绩效多少
  • 财务会计制度及核算软件备案怎么填
  • 免责声明:网站部分图片文字素材来源于网络,如有侵权,请及时告知,我们会第一时间删除,谢谢! 邮箱:opceo@qq.com

    鄂ICP备2023003026号

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

    友情链接: 武汉网站建设