update reademe
This commit is contained in:
15
README.md
15
README.md
@@ -2,6 +2,7 @@
|
||||
Android 自定义方形输入框,仿滴滴验证码、小篮单车验证码输入框
|
||||
|
||||
##效果图
|
||||
|
||||

|
||||
|
||||
GIF被压缩的有点模糊,下面是截图
|
||||
@@ -109,7 +110,17 @@ Step 2. Add the dependency
|
||||
|
||||
```
|
||||
dependencies {
|
||||
compile 'com.jyn.verificationcodeview:verificationcodeview:1.0.0'
|
||||
|
||||
compile 'com.jyn.verificationcodeview:verificationcodeview:1.0.0'
|
||||
}
|
||||
```
|
||||
|
||||
## 开发思路
|
||||
简书:[http://www.jianshu.com/p/781950fe5e73](http://www.jianshu.com/p/781950fe5e73)
|
||||
CSDN:[http://blog.csdn.net/jiaoyaning1210/article/details/78427818](http://blog.csdn.net/jiaoyaning1210/article/details/78427818)
|
||||
|
||||
---
|
||||
|
||||
如果对您有帮助的话,还请给个收藏或者star,谢谢!
|
||||
|
||||
---
|
||||
|
||||
|
||||
@@ -158,7 +158,7 @@ public class VerificationCodeView extends LinearLayout implements TextWatcher, V
|
||||
EditText editText = new EditText(mContext);
|
||||
initEditText(editText, i);
|
||||
addView(editText);
|
||||
if (i == 0) {
|
||||
if (i == 0) { //设置第一个editText获取焦点
|
||||
editText.setFocusable(true);
|
||||
}
|
||||
}
|
||||
@@ -256,6 +256,7 @@ public class VerificationCodeView extends LinearLayout implements TextWatcher, V
|
||||
private void focus() {
|
||||
int count = getChildCount();
|
||||
EditText editText;
|
||||
//利用for循环找出还最前面那个还没被输入字符的EditText,并把焦点移交给它。
|
||||
for (int i = 0; i < count; i++) {
|
||||
editText = (EditText) getChildAt(i);
|
||||
if (editText.getText().length() < 1) {
|
||||
@@ -266,16 +267,18 @@ public class VerificationCodeView extends LinearLayout implements TextWatcher, V
|
||||
editText.setCursorVisible(false);
|
||||
}
|
||||
}
|
||||
//如果最后一个输入框有字符,则返回结果
|
||||
EditText lastEditText = (EditText) getChildAt(mEtNumber - 1);
|
||||
if (lastEditText.getText().length() > 0) {
|
||||
lastEditText.requestFocus();
|
||||
getResult();
|
||||
}
|
||||
}
|
||||
|
||||
private void backFocus() {
|
||||
//博主手机不好,经常点一次却触发两次`onKey`事件,就设置了一个防止多点击,间隔100毫秒。
|
||||
long startTime = System.currentTimeMillis();
|
||||
EditText editText;
|
||||
//循环检测有字符的`editText`,把其置空,并获取焦点。
|
||||
for (int i = mEtNumber - 1; i >= 0; i--) {
|
||||
editText = (EditText) getChildAt(i);
|
||||
if (editText.getText().length() >= 1 && startTime - endTime > 100) {
|
||||
|
||||
Reference in New Issue
Block a user