iis服务器助手广告广告
返回顶部
首页 > 资讯 > 移动开发 >Android 自定义对话框 showSetPwdDialog
  • 148
分享到

Android 自定义对话框 showSetPwdDialog

自定义Android 2022-06-06 08:06:48 148人浏览 八月长安
摘要

样式如下所示: 布局: layout   dialog_set_pwd.xml <?xml version="." encoding="utf-"&

样式如下所示:

布局:

layout

  dialog_set_pwd.xml


<?xml version="." encoding="utf-"?>
<LinearLayout xmlns:Android="Http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#EFEFEF"
android:orientation="horizontal"
android:padding="dp" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/dialog_title_default_icon" />
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="dp"
android:text="设置密码"
android:textColor="@color/black"
android:textSize="sp" />
</LinearLayout>
<EditText
android:id="@+id/et_pwd"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="dp"
android:hint="请输入密码"
android:inputType="textPassWord" >
</EditText>
<EditText
android:id="@+id/et_pwd_confirm"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="dp"
android:hint="请再次输入密码"
android:inputType="textPassword" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="dp" >
<Button
android:id="@+id/btn_ok"
android:layout_width="dp"
android:layout_height="wrap_content"
android:layout_weight=""
android:background="@drawable/btn_blue_selector"
android:text="确定"
android:layout_marginRight="dp"
android:textColor="@color/white" />
<Button
android:id="@+id/btn_cancel"
android:layout_width="dp"
android:layout_height="wrap_content"
android:layout_weight=""
android:background="@drawable/btn_white_selector"
android:text="取消"
android:textColor="@color/black" />
</LinearLayout>
</LinearLayout>

状态选择器:

drawable

  btn_blue_selector.xml


<?xml version="." encoding="utf-"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/dg_btn_confirm_select" android:state_pressed="true"></item>
<item android:drawable="@drawable/dg_btn_confirm_nORMal"></item>
</selector>

  btn_white_selector.xml


<?xml version="." encoding="utf-"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/dg_button_cancel_select" android:state_pressed="true"></item>
<item android:drawable="@drawable/dg_button_cancel_normal"></item>
</selector>

引用值

values

  colors.xml


<?xml version="." encoding="utf-"?>
<resources>
<color name="black">#</color>
<color name="gray">#a</color>
<color name="white">#fff</color>
<color name="red">#f</color>
<color name="shape_setting_normal">#BDEE</color>
<color name="shape_setting_pressed">#CAD</color>
<color name="blue">#FD</color>
<color name="light_green">#f</color>
</resources> 

代码:


private void showSetPwdDialog() {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
View view = View.inflate(this, R.layout.dialog_set_pwd, null);
Button btnOk = (Button) view.findViewById(R.id.btn_ok);
Button btnCancel = (Button) view.findViewById(R.id.btn_cancel);
final EditText etPwd = (EditText) view.findViewById(R.id.et_pwd);
final EditText etPwdConfirm = (EditText) view
.findViewById(R.id.et_pwd_confirm);
builder.setView(view);//将当前布局对象设置给dialog
final AlertDialog dialog = builder.create();
btnOk.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
String pwd = etPwd.getText().toString().trim();
String pwdConfirm = etPwdConfirm.getText().toString().trim();
if (TextUtils.isEmpty(pwd) || TextUtils.isEmpty(pwdConfirm)) {
ToastUtils.showToast(getApplicationContext(), "输入内容不能为空!");
} else {
if (pwd.equals(pwdConfirm)) {
System.out.println("登录成功!");
//将密码保存在本地sp
PrefUtils.putString(getApplicationContext(),
GlobalConstants.PREF_PASSWORD,
MDUtils.getMd(pwd));
dialog.dismiss();
enterLostAndFindPage();
} else {
ToastUtils.showToast(getApplicationContext(),
"两次密码不一致!");
}
}
}
});
btnCancel.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
dialog.dismiss();
}
});
dialog.show();
}

有关Android 自定义对话框 showSetPwdDialog,小编就给大家介绍这么多,希望对大家有所帮助!

您可能感兴趣的文章:Android中自定义对话框(Dialog)的实例代码Android使用setCustomTitle()方法自定义对话框标题ANDROID中自定义对话框AlertDialog使用示例Android常用的AlertDialog对话框及自定义对话框Android自定义对话框Dialog的简单实现Android 根据EditText搜索框ListView动态显示数据Android控件系列之EditText使用方法Android中实现EditText圆角的方法Android EditText常用属性功能汇总Android EditText自定义样式的方法Android编程实现在自定义对话框中获取EditText中数据的方法


--结束END--

本文标题: Android 自定义对话框 showSetPwdDialog

本文链接: https://www.lsjlt.com/news/25372.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

本篇文章演示代码以及资料文档资料下载

下载Word文档到电脑,方便收藏和打印~

下载Word文档
猜你喜欢
  • android如何自定义对话框
    这篇文章给大家分享的是有关android如何自定义对话框的内容。小编觉得挺实用的,因此分享给大家做个参考,一起跟随小编过来看看吧。实现效果  定义dialog.xml (res/layout/dialog.xml)<...
    99+
    2023-06-22
  • Android studio自定义对话框效果
    本文实例为大家分享了Android studio自定义对话框效果的具体代码,供大家参考,具体内容如下 实现步骤: 第一步:自定义.xml布局文件 <?xml ver...
    99+
    2024-04-02
  • Android中如何自定义对话框
    本文小编为大家详细介绍“Android中如何自定义对话框”,内容详细,步骤清晰,细节处理妥当,希望这篇“Android中如何自定义对话框”文章能帮助大家解决疑惑,下面跟着小编的思路慢慢深入,一起来学习新知识吧。本文测试的harbor的版本是...
    99+
    2023-06-29
  • android自定义带箭头对话框
    本文实例为大家分享了android自定义带箭头对话框的具体代码,供大家参考,具体内容如下 import android.content.Context; import andr...
    99+
    2024-04-02
  • android自定义对话框实例代码
    1.实现效果    2.定义dialog.xml (res/layout/dialog.xml) <?xml version="1.0" encoding="utf...
    99+
    2024-04-02
  • Android自定义对话框的简单实现
    本文实例为大家分享了Android自定义对话框的具体实现代码,供大家参考,具体内容如下 1、定义对话框的布局 <xml version="1.0" encoding="utf-...
    99+
    2024-04-02
  • Android自定义样式圆角dialog对话框
    本文实例为大家分享了Android创建自定义样式圆角dialog对话框的具体代码,供大家参考,具体内容如下 效果如上,圆角对话框,标题和正文都可以自己设定 做法: 1.在res文件...
    99+
    2024-04-02
  • Android Studio使用自定义对话框效果
    Android Studio基础使用自定义对话框,供大家参考,具体内容如下 兼容低版本的APP运行 第一步:新建新的空白activity,布局XML设置如下 该APP的启动界面ac...
    99+
    2024-04-02
  • Android自定义对话框Dialog的简单实现
    本文着重研究了自定义对话框,通过一下步骤即可清晰的理解原理,通过更改界面设置和style类型,可以应用在各种各样适合自己的App中。首先来看一下效果图:首先是activity的界面点击了上述图片的按钮后,弹出对话框:点击对话框的确定按钮:点...
    99+
    2023-05-30
    android 对话框 dialog
  • Android如何自定义输入文本对话框?
    文章目录 0.引言1.创建示例工程2.输入文本对话框布局和功能设计3.主程序调用输入文本对话框 0.引言   笔者研究的课题涉及到安卓软件开发,在开发过程中,发现普通的显示消息对话框一般可...
    99+
    2023-10-26
    android java android studio
  • Android中怎么自定义AlertDialog对话框样式
    这篇文章给大家介绍Android中怎么自定义AlertDialog对话框样式,内容非常详细,感兴趣的小伙伴们可以参考借鉴,希望对大家能有所帮助。根据自己实际的需求,为AlertDialog创建一个布局,在此我需要定义一个如图所示的WIFI密...
    99+
    2023-05-30
    android alertdialog
  • Android Studio怎么使用自定义对话框效果
    这篇文章主要介绍了Android Studio怎么使用自定义对话框效果的相关知识,内容详细易懂,操作简单快捷,具有一定借鉴价值,相信大家阅读完这篇Android Studio怎么使用自定义对话框效果文章都会有所收获,下面...
    99+
    2023-06-30
  • Android怎么自定义样式圆角dialog对话框
    这篇文章主要介绍“Android怎么自定义样式圆角dialog对话框”,在日常操作中,相信很多人在Android怎么自定义样式圆角dialog对话框问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答”Android...
    99+
    2023-06-25
  • Android如何自定义升级对话框示例详解
    前言本文主要给大家介绍了关于Android自定义升级对话框的相关内容,分享出来供大家参考学习,下面话不多说了,来一起看看详细的介绍吧。实现的效果如下所示其实这也只是一个DialogFragment 而已,重点只是在于界面的设计想要使用做出这...
    99+
    2023-05-30
    android 自定义 升级对话框
  • Android中怎么自定义对话框位置及大小
    Android中怎么自定义对话框位置及大小,针对这个问题,这篇文章详细介绍了相对应的分析和解答,希望可以帮助更多想解决这个问题的小伙伴找到更简单易行的方法。代码:package angel.devil;import an...
    99+
    2023-05-30
    android
  • Vue自定义模态对话框弹窗
    本文实例为大家分享了Vue自定义模态对话框弹窗的具体代码,供大家参考,具体内容如下 模态对话框弹窗效果: 父组件(应用页面)主要代码: <template>     &...
    99+
    2024-04-02
  • 怎么在Android中自定义一个扁平化对话框
    这篇文章给大家介绍怎么在Android中自定义一个扁平化对话框,内容非常详细,感兴趣的小伙伴们可以参考借鉴,希望对大家能有所帮助。Shamoo想到在Android平台上弄一个扁平化的对话框。参考过一篇帖子,然后改了一下。这个Demo比较简单...
    99+
    2023-05-31
    android
  • Android 自定义弹出菜单和对话框功能实例代码
    Android 开发当中,可能会存在许多自定义布局的需求,比如自定义弹出菜单(popupWindow),以及自定义对话框(Dialog)。话不多说,直接上图片。 先讲第一种,自定义PopUpWindow1.popupWindowp...
    99+
    2023-05-30
    android 弹出菜单 对话框
  • Vue怎么自定义模态对话框弹窗
    这篇文章主要介绍“Vue怎么自定义模态对话框弹窗”的相关知识,小编通过实际案例向大家展示操作过程,操作方法简单快捷,实用性强,希望这篇“Vue怎么自定义模态对话框弹窗”文章能帮助大家解决问题。模态对话框弹窗效果:父组件(应用页面)主要代码:...
    99+
    2023-07-02
  • Android编程实现AlertDialog自定义弹出对话框的方法示例
    本文实例讲述了Android编程实现AlertDialog自定义弹出对话框的方法。分享给大家供大家参考,具体如下:弹出对话框,显示自定义的布局文件弹出对话框提示设置密码或登录密码private void showSetPasswordDia...
    99+
    2023-05-30
    android alertdialog 对话框
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作