Detect if Edittext is a password field

856 views
Skip to first unread message

Idell

unread,
Nov 26, 2013, 12:06:19 PM11/26/13
to robotium-...@googlegroups.com
Hi, 
there is a way to use robotium to detect if a given edittext is a password field, when the relative android:hint is empty? 
Thank's

Pawel Wojnarowicz

unread,
Dec 1, 2013, 2:11:30 PM12/1/13
to robotium-...@googlegroups.com
You can check an input type value returned by the getInputType method. Sample code for detecting a text password field:


if ((editText.getInputType() & InputType.TYPE_TEXT_VARIATION_PASSWORD) == InputType.TYPE_TEXT_VARIATION_PASSWORD){

   //editText is a text password field

}


There are some other password types (i.e. number or visible to the user) you may want to check against. More info at http://developer.android.com/reference/android/text/InputType.html

Idell

unread,
Dec 2, 2013, 6:21:34 AM12/2/13
to robotium-...@googlegroups.com
Seems that works, thank's for the answer!

Gokul Karthik

unread,
Mar 17, 2015, 9:05:03 AM3/17/15
to robotium-...@googlegroups.com

Why you did not type like this 

if (editText.getInputType() == InputType.TYPE_TEXT_VARIATION_PASSWORD){

   //editText is a text password field

}

Because both r return int value right ?


Reply all
Reply to author
Forward
0 new messages