带有文本密码输入类型的Android EditText不';t双击选择所有字符
我正在尝试将带有文本密码输入类型的Android EditText不';t双击选择所有字符,android,android-edittext,passwords,selectall,Android,Android Edittext,Passwords,Selectall,我正在尝试将EditText与textPassword输入类型一起使用。我面临的情况是,在android版本5和4.4中,所有输入字段的字符都是通过双击选择的,而在android版本6中,该功能不起作用。 你能帮我在所有android版本中都使用这个功能吗 这是我的xml文件: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/ap
EditText
与textPassword
输入类型一起使用。我面临的情况是,在android版本5和4.4中,所有输入字段的字符都是通过双击选择的,而在android版本6中,该功能不起作用。
你能帮我在所有android版本中都使用这个功能吗
这是我的xml文件:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<EditText
android:hint="Text Password Input Type"
android:inputType="textPassword"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
结果是:
一般算法是:
private long timeLastClicked;
private static final TIME_DOUBLE_CLICK_MS = 1000;
private EditText passwordField; //should put the result of findViewById in here
...
myEditText.setOnClickListener(new OnClickListener() {
public void onClick(View view) {
long time = System.currentTimeMillis();
if(time - timeLastClicked < TIME_DOUBLE_CLICK_MS) {
passwordField.setSelection(0,passwordField.getText().length());
}
timeLastClicked = time;
});
private长时间单击;
私有静态最终时间\u双击\u MS=1000;
私有文本密码字段//应该把findViewById的结果放在这里
...
myEditText.setOnClickListener(新的OnClickListener(){
公共void onClick(视图){
长时间=System.currentTimeMillis();
如果(时间-timeLastClicked
它的作用-它设置了一个点击监听器。当你看到一个点击时,你会检查你是否在前一秒看到另一个点击。如果是,你会点亮文本。如果不是,你不会。无论哪种方式,你都会节省这次点击的时间,以便你下次可以比较它。我想这个问题只存在于模拟器上,而不是真实的device@VVB此功能在三星Note 4上用棒棒糖检查,Nexus 5上用棉花糖android版本检查。出现了相同的结果。你测试过这个解决方案吗?对我不起作用。问题似乎与setSelection()方法有关。因为算法是正确的。