Home > Blockchain >  How to get the value of characters while typing in edit text box in another text box َ?
How to get the value of characters while typing in edit text box in another text box َ?

Time:01-05

How can get the values of the characters in a Text box while typing in the edit text box of Android Studio ? For example, if the user writes A in the edit text box, then in the second text box, the value of A should be seen as 20. Similarly, the other characters should be given a specific value.

        textView.setText(editText.getText().toString())

CodePudding user response:

Take a look at TextWatcher - 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);

CodePudding user response:

Use Textwatcher and convert like this

val codeValue = 'A'.code // 'A' dynamic
textView.setText(codeValue.toString())

CodePudding user response:

Use TextWatcher

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){}
    });
  • Related