editText_SerialCode = (EditText) findViewById(R.id.editText_SerialCode); editText_SerialCode.addTextChangedListener(textWatcher); private TextWatcher textWatcher = new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void afterTextChanged(Editable s) { String str=s.toString(); str=str.toUpperCase(); editText_SerialCode.setText(str); editText_SerialCode.setSelection(str.length()); } };
备忘: Android中把EditText的输入内容转为大写
时间: 2024-10-01 10:26:39