Skip to content
This repository was archived by the owner on Jun 3, 2021. It is now read-only.

Commit e5b6688

Browse files
chenfengYorkShen
authored andcommitted
[WEEX-490][android] fix the bug of input component when setting property "type=tel" and "type=number" in input component,users can also input text
Bug: 490
1 parent 6d4da70 commit e5b6688

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

android/sdk/src/main/java/com/taobao/weex/ui/component/AbstractEditComponent.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import android.text.TextPaint;
2828
import android.text.TextUtils;
2929
import android.text.TextWatcher;
30+
import android.text.method.DigitsKeyListener;
3031
import android.text.method.PasswordTransformationMethod;
3132
import android.util.Log;
3233
import android.util.TypedValue;
@@ -655,6 +656,8 @@ public void setMaxlength(int maxLength) {
655656
}
656657

657658
private int getInputType(String type) {
659+
String digits = "1234567890";
660+
String digitsWithDot = "12234567890.";
658661
int inputType;
659662
switch (type) {
660663
case Constants.Value.TEXT:
@@ -676,6 +679,7 @@ private int getInputType(String type) {
676679
break;
677680
case Constants.Value.TEL:
678681
inputType = InputType.TYPE_CLASS_PHONE;
682+
getHostView().setKeyListener(DigitsKeyListener.getInstance(digits));
679683
break;
680684
case Constants.Value.TIME:
681685
inputType = InputType.TYPE_NULL;
@@ -686,6 +690,7 @@ private int getInputType(String type) {
686690
break;
687691
case Constants.Value.NUMBER:
688692
inputType = InputType.TYPE_CLASS_NUMBER;
693+
getHostView().setKeyListener(DigitsKeyListener.getInstance(digitsWithDot));
689694
break;
690695
default:
691696
inputType = InputType.TYPE_CLASS_TEXT;

0 commit comments

Comments
 (0)