如何在Android Studio的编辑文本框中输入文本框中字符的值?例如,如果用户在编辑文本框中写入A,那么在第二个文本框中,A的值应该显示为20。同样地,其他字符也应该指定一个特定的值。
textView.setText(editText.getText().toString())
看看texttwatcher - https://developer.android.com/reference/android/text/TextWatcher
TextWatcher textWatcher = new TextWatcher() {
@Override
public void onTextChanged(CharSequence charSequence, int start, int before, int count) {
...
}
...
};
textView.addTextChangedListener(textWatcher);
使用文本观察器并像这样转换
val codeValue = 'A'.code // 'A' dynamic
textView.setText(codeValue.toString())
使用texttwatcher
youredittext.addTextChangedListener(new TextWatcher()
{
@Override
public void afterTextChanged(Editable mEdit)
{
text = mEdit.toString();
textView.setText(text)
}
public void beforeTextChanged(CharSequence s, int start, int count, int after){}
public void onTextChanged(CharSequence s, int start, int before, int count){}
});