Edittext不可编辑可点击,输入密码可见与不可见,验证码换格输入实现方法,车牌号自定义输入键盘

不可编辑可点击:设置两个属性即可

mEdittext.setFocusable(false);
mEdittext.setOnClickListener(this::onClick);

输入密码可见与不可见

 

private boolean ifonpenteyes=true;
if (ifonpenteyes){
    ifshowpawimage.setImageResource(R.mipmap.openeyes);
    login_pasw.setInputType(InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD);
    login_pasw.setSelection(login_pasw.getText().length());
    ifonpenteyes = !ifonpenteyes;
}else {
    ifshowpawimage.setImageResource(R.mipmap.closeeyes);
    login_pasw.setInputType(InputType.TYPE_TEXT_VARIATION_PASSWORD| InputType.TYPE_CLASS_TEXT);
    login_pasw.setSelection(login_pasw.getText().length());
    ifonpenteyes = !ifonpenteyes;
}
xml文件

<EditText
    android:id="@+id/login_pasw"
    android:layout_width="0dp"
    android:layout_weight="5"
    android:layout_height="20dp"
    android:layout_marginLeft="6dp"
    android:background="@null"
    android:gravity="center_vertical"
    android:hint="@string/mm"
    android:imeOptions="actionNext"
    android:inputType="textPassword"
    android:maxLines="1"
    android:singleLine="true"
    android:digits="@string/pwd_limit"
    android:textColor="@color/text_color_dark_black"
    android:textColorHint="@color/text_color_cdcdcd"
    android:textCursorDrawable="@drawable/editcolor"
    android:textSize="16sp" />
 

效果:

 

 

3、输入验证码,密码换个输入实现

适配依赖

implementation 'com.github.licheedev.CommonSize:common_size_w750_n1000:1.3'

 

 布局文件

<RelativeLayoutandroid:layout_width="@dimen/normal_605dp"android:layout_height="@dimen/normal_100dp"android:layout_marginTop="@dimen/normal_550dp"><LinearLayoutandroid:layout_width="@dimen/normal_605dp"android:layout_height="@dimen/normal_100dp"android:background="@drawable/bg_ed_5dp"android:gravity="center_vertical"><TextViewandroid:id="@+id/ed1"android:layout_width="@dimen/normal_100dp"android:layout_height="@dimen/normal_100dp"android:gravity="center"android:inputType="textPassword"android:textColor="@color/color_333"android:textSize="@dimen/normal_32dp" /><Viewandroid:layout_width="@dimen/normal_1dp"android:layout_height="@dimen/normal_80dp"android:background="@color/color_EF611E"/><TextViewandroid:id="@+id/ed2"android:layout_width="@dimen/normal_100dp"android:layout_height="@dimen/normal_100dp"android:textSize="@dimen/normal_32dp"android:textColor="@color/color_333"android:gravity="center"/><Viewandroid:layout_width="@dimen/normal_1dp"android:layout_height="@dimen/normal_80dp"android:background="@color/color_EF611E"/><TextViewandroid:id="@+id/ed3"android:layout_width="@dimen/normal_100dp"android:layout_height="@dimen/normal_100dp"android:textSize="@dimen/normal_32dp"android:textColor="@color/color_333"android:inputType="textPassword"android:gravity="center"/><Viewandroid:layout_width="@dimen/normal_1dp"android:layout_height="@dimen/normal_80dp"android:background="@color/color_EF611E"/><TextViewandroid:id="@+id/ed4"android:layout_width="@dimen/normal_100dp"android:layout_height="@dimen/normal_100dp"android:textSize="@dimen/normal_32dp"android:textColor="@color/color_333"android:inputType="textPassword"android:gravity="center"/><Viewandroid:layout_width="@dimen/normal_1dp"android:layout_height="@dimen/normal_80dp"android:background="@color/color_EF611E"/><TextViewandroid:id="@+id/ed5"android:layout_width="@dimen/normal_100dp"android:layout_height="@dimen/normal_100dp"android:textSize="@dimen/normal_32dp"android:textColor="@color/color_333"android:inputType="textPassword"android:gravity="center"/><Viewandroid:layout_width="@dimen/normal_1dp"android:layout_height="@dimen/normal_80dp"android:background="@color/color_EF611E"/><TextViewandroid:id="@+id/ed6"android:layout_width="@dimen/normal_100dp"android:layout_height="@dimen/normal_100dp"android:textSize="@dimen/normal_32dp"android:textColor="@color/color_333"android:inputType="textPassword"android:gravity="center"/></LinearLayout><EditTextandroid:id="@+id/edEnter"android:layout_width="match_parent"android:layout_height="match_parent"android:background="@color/transparent"android:textColor="@color/transparent"android:inputType="numberPassword"android:cursorVisible="false"android:maxLength="6"/></RelativeLayout>

实现代码

@BindView(R.id.ed1)
TextView mEd1;
@BindView(R.id.ed2)
TextView mEd2;
@BindView(R.id.ed3)
TextView mEd3;
@BindView(R.id.ed4)
TextView mEd4;
@BindView(R.id.ed5)
TextView mEd5;
@BindView(R.id.ed6)
TextView mEd6;
@BindView(R.id.edEnter)
EditText mEdEnter;

 

ButterKnife.bind(this);edTexts = new ArrayList<>(Arrays.asList(mEd1, mEd2, mEd3, mEd4, mEd5, mEd6));mEdEnter.addTextChangedListener(new TextWatcher() {@Overridepublic void beforeTextChanged(CharSequence s, int i, int i1, int i2) {}@Overridepublic void onTextChanged(CharSequence s, int i, int i1, int i2) {//toast("您输入的数据为:" + s.toString());}@Overridepublic void afterTextChanged(Editable editable) {String s = mEdEnter.getText().toString();char[] chars = s.toCharArray();for (TextView edText : edTexts) {edText.setText("");}for (int i = 0; i < chars.length; i++) {edTexts.get(i).setText(chars[i]+"");}}
});

 

资源

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"><stroke android:width="@dimen/normal_1dp" android:color="@color/color_EF611E"/><corners android:radius="@dimen/normal_5dp"/></shape>
<color name="color_EF611E">#EF611E</color><color name="color_333">#333333</color>

 实现效果——换格输入框

车牌号自定义输入实现demo

 

 

 

 

自定义键盘

demo链接: https://download.csdn.net/download/meixi_android/16635556

这些bug交流:QQ1085220040 

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/415376.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

小程序button去除边框

在小程序给官方button增加自定义样式的时候&#xff0c;需要注意隐藏button的border。 我用的less&#xff0c;加上一行代码就可以解决。 &:after {border: none; }例如下图自定义样式的代码是 .login-btn {background: #ecb810;color: #2e2f2e;display: flex;align-ite…

Alpha 冲刺 (7/10)

队名&#xff1a;天机组 组员1友林 228&#xff08;组长&#xff09; 今日完成&#xff1a;get到了一份对winsock各功能封装好的代码明天计划&#xff1a;继续封装剩余任务&#xff1a;对接主要困难&#xff1a;头文件迷之出错收获及疑问&#xff1a;加深了c以及java类的理解本…

签名验签自助排查

签名验签自助排查 支付宝开放平台SDK封装了签名和验签过程&#xff0c;只需配置账号及密钥参数&#xff0c;强烈建议使用。 SDK下载地址 TIPS&#xff1a;文中代码部分以JAVA语言演示&#xff0c;其他语言请参考各自SDK。 使用开放平台SDK接入 如果使用了开放平台SDK&#xff…

微信小程序 WXBizDataCrypt 解密 报错

在使用微信官方WXBizDataCrypt.js解密encryptedData获取敏感数据的时候&#xff0c;偶尔会报错。 DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(),Buffer.allocUnsafe(), or Buffer.from() methods inste…

表单提交中的input、button、submit的区别

参考博文&#xff1a;http://www.cnblogs.com/shytong/p/5087147.html 设置typesubmit后&#xff0c;输入控件会变成一个按钮&#xff0c;显示的文字为其value值&#xff0c;默认值是Submit。form[method]默认值为GET&#xff0c;所以提交后会使用GET方式进行页面跳转。input[t…

java.lang.ClassNotFoundException

5.0以下报错&#xff1a;java.lang.ClassNotFoundExceptionxxxx.。5.0以上不会报错 解决方法&#xff1a; 在Application的onCreate()里加 MultiDex.install(this);

小程序 authorize scope.userLocation 需要在app.json中声明permission字段

使用wx.authorize遇到的一个小问题&#xff0c;解决办法就是在app.json中增加permission字段。 官方地址&#xff1a;https://developers.weixin.qq.com/miniprogram/dev/reference/configuration/app.html

Android 图片选择器、图片剪切,文件选择器

单张图片选择 1、在build.gradle中dependencies下添加依赖 compile com.github.lovetuzitong:MultiImageSelector:1.2 2、完整activity代码 public class MainActivity extends AppCompatActivity {private static final int REQUEST_IMAGE3 5;public final static int MS…

【洛谷P3389】【模板】高斯消元

题目链接 题目描述 给定一个线性方程组&#xff0c;对其求解 输入输出格式 输入格式&#xff1a; 第一行&#xff0c;一个正整数 n 第二至 n1行&#xff0c;每行 n1 个整数&#xff0c;为a1, a2 .....an​ 和 b&#xff0c;代表一组方程。 输出格式&#xff1a; 共n行&#xff…

微信小程序上传的视频显示封面 我是阿里云oss的实现

我们一般用wx.chooseVideo拍摄视频或从手机相册中选视频&#xff0c;然后上传到后台存储空间。 但是给用户显示视频列表的时候&#xff0c;需要视频封面额。 阿里oss地址&#xff1a;https://help.aliyun.com/document_detail/64555.html?spm5176.11065259.1996646101.searc…

Android 仿微信多张图片选择器,适配android10系统,open failed: EACCES (Permission denied)

实现效果 只需引入模块&#xff0c;比起依赖&#xff0c;更方便自定义 implementation project(:imagepicker) //图片加载 implementation com.github.bumptech.glide:glide:4.11.0 初始化即可使用 private void initImagePicker() {ImagePicker imagePicker ImagePicker.g…

前端学习(2638):读懂代码之登录页login.vue之ref和rules

<template><div class"login-wrap"><div class"ms-login"><div class"ms-title">后台管理系统</div><!--1定义参数类型 2定义路由规则 3使用ref去进行指向 --><el-form :model"param" :rules&…

mongodb save和insert区别

mongodb的save和insert函数都可以向collection里插入数据&#xff0c;但两者是有两个区别&#xff1a; 一、使用save函数里&#xff0c;如果原来的对象不存在&#xff0c;那他们都可以向collection里插入数据&#xff0c;如果已经存在&#xff0c;save会调用update更新里面的记…

P1967 货车运输

P1967 货车运输最大生成树lca并查集 1 #include<iostream>2 #include<cstdio>3 #include<queue>4 #include<algorithm>5 #include<cmath>6 #include<ctime>7 #include<set>8 #include<map>9 #include<stack>10 #include…

前端学习(2640):懂代码之登录页login.vue存入用户信息

<template><div class"login-wrap"><div class"ms-login"><div class"ms-title">后台管理系统</div><!--1定义参数类型 2定义路由规则 3使用ref去进行指向 --><el-form :model"param" :rules&…

js 根据时间生成唯一订单号

一般做唯一编号的时候&#xff0c;可以使用guid或者uuid的包直接生成&#xff0c;但是我希望唯一编号能够反应生成的时间信息&#xff0c;所以就准备使用日期随机值来构造&#xff0c;代码如下&#xff1a; const tradeNo function () {const now new Date()const year now…

(转) 并发处理

1、使用事物 2、使用消息队列 可以基于例如MemcacheQ等这样的消息队列。 比如有100张票可供用户抢&#xff0c;那么就可以把这100张票放到缓存中&#xff0c;读写时不要加锁。 当并发量大的时候&#xff0c;可能有500人左右抢票成功&#xff0c;这样对于500后面的请求可以直接转…

js将字符串 YYMMDDHHmmss 转化为 date类型

微信支付的回调参数time_end为日期字符串。 需求&#xff1a;将20190523101156转化为转换为Date日期格式Thu May 23 2019 10:11:56 GMT0800 (中国标准时间) const str2date (dateString)> {const pattern /(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/;return new Dat…

Android 自定义带图标Toast,工具方法,Toast自定义显示时间

带图标Toast工具方法1 public static void show(Context act, String strContent, int iResouce){try {Toast toast new Toast(act);View view LayoutInflater.from(act).inflate(R.layout.layout_dialog_toastok, null);TextView tvContent view.findViewById(R.id.content…

This relative module was not found ./cptable webpack

在使用xlsx库的时候遇到的报错。 This relative module was not found: * ./cptable in ./node_modules/xlsx-style/dist/cpexcel.js记录解决方法&#xff0c;我是使用webpack进行配置的。 在chainWebpack里面增加一行代码&#xff0c;重新编译&#xff0c;即可。 config.ext…