为什么显示 InputType 密码?
Why InputType password is shown?
我的代码:
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());
所以代码是这样的:
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());
在 XML
试试这个:
<EditText
android:id="@+id/txtPassword"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textPassword" >
</EditText>
试试这个
input.setTransformationMethod(new PasswordTransformationMethod());
我的代码:
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());
所以代码是这样的:
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());
在 XML
试试这个:
<EditText
android:id="@+id/txtPassword"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textPassword" >
</EditText>
试试这个
input.setTransformationMethod(new PasswordTransformationMethod());