1

My code :

final EditText input = new EditText(VideoRunActivity.this);
        LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
                LinearLayout.LayoutParams.MATCH_PARENT,
                LinearLayout.LayoutParams.MATCH_PARENT);
        input.setLayoutParams(lp);
        input.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);

It shows the input which is typed by me. Thanks in advance.

H.M Maruf
  • 65
  • 12

3 Answers3

0

Try do this:

input.setTransformationMethod(PasswordTransformationMethod.getInstance());

So code be like that:

    final EditText input = new EditText(VideoRunActivity.this);
            LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
                    LinearLayout.LayoutParams.MATCH_PARENT,
                    LinearLayout.LayoutParams.MATCH_PARENT);
            input.setLayoutParams(lp);
            input.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
input.setTransformationMethod(PasswordTransformationMethod.getInstance());
Bruno Ferreira
  • 1,561
  • 1
  • 10
  • 17
0

Try this in XML:

<EditText
        android:id="@+id/txtPassword"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:inputType="textPassword" >
</EditText>
H.M Maruf
  • 65
  • 12
0

try this out

input.setTransformationMethod(new PasswordTransformationMethod());
Ashish Kumar
  • 374
  • 4
  • 11
  • 1
    You better explain your solution instead of simply posting some code. Maybe it's worth reading [How to write a good answer](https://stackoverflow.com/help/how-to-answer). – Massimiliano Kraus Aug 07 '17 at 11:41