Android EditText with text password input type doesn't select all character by double tap -
i'm trying use edittext
textpassword
input type. faced situation in characters entering in field selected double tap in android version 5 , 4.4 while feature didn't work on android version 6. please me have feature in android versions?
this xml file:
<?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>
this result:
the general algorithm be:
private long timelastclicked; private static final time_double_click_ms = 1000; private edittext passwordfield; //should put 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; });
what does- sets click listener. when see click, check if saw click in previous second. if so, hilight text. if not, don't. either way, save time of click can compare next time.
Comments
Post a Comment