I hope that this has not been asked yet, since I could not find it. I am trying to get a username and password for an online service. I created a TextView username and TextView password. I can get the text from the TextView username without problems. However, I cannot get anything from the TextView password. The following is the XML:
<TextView android:id="@+id/user_password" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_horizontal" android:layout_marginTop="8dp" android:text="@string/passcodeQuery" android:textAppearance="?android:attr/textAppearanceLarge" /> <EditText android:id="@+id/editText2" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginLeft="8dp" android:layout_marginRight="8dp" android:layout_marginTop="8dp" android:hint="@string/passwordHint" android:inputType="textPassword" />
The problem is that if I run the code
TextView passField = (TextView)findViewById(R.id.user_password);
then
String toastMessage = "Password: " + passField.getText().toString();
No matter what I entered in the password field, the toast message gives me
Password: Password
Obviously, I will not fry the user password normally, I just do it now because I want to make sure that I read the input correctly. Unfortunately, this does not seem to be the case, as I cannot read the password field. How do you get around this? The tone of the application seems to be able to do this. Is there an easier way to get a password than what I'm doing?
source share