<EditText android:id="@+id/et_2" android:layout_width="match_parent" android:layout_height="50dp" android:textColor="#FFC107" android:layout_below="@i ...
<EditText
android:id="@+id/et_2"
android:layout_width="match_parent"
android:layout_height="50dp"
android:textColor="#FFC107"
android:layout_below="@id/et_1"
android:layout_marginTop="10dp"
android:textSize="20sp"
android:drawableLeft="@drawable/passwor"
android:drawablePadding="10dp"
android:hint="密碼"
android:maxLength="1"
android:inputType="textPassword"*顯示
android:inputType="number" 呼出數字鍵
android:background="@drawable/bg_username"
android:paddingLeft="10dp"
/>
監控EditText輸入(可以再LogCat中看到輸入)
mEtUserName=findViewById(R.id.et_1);
mEtUserName.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
Log.d("edittext",s.toString());
}
@Override
public void afterTextChanged(Editable s) {
}