Skip to content Skip to sidebar Skip to footer

How To Get A Result Data To Edit Text Without Clicking On Button?

I created a converter app, I used 2 edit text one which gets input and other display output it will display output by clicking on button is there any way to get the output display

Solution 1:

you can use TextWatcher for this purpose. You wil get the each character value in this listener.. Update your output editText according to your needs

editText1.addTextChangedListener(new TextWatcher() {
            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {

                // TODO Auto-generated method stub
            }

            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {

                // TODO Auto-generated method stub
            }

            @Override
            public void afterTextChanged(Editable s) {

                // Place the logic here for your output edittext
            }
        });

Solution 2:

yes you can you by detecting keyboard action done

i.e.

et.setOnEditorActionListener(newTextView.OnEditorActionListener() {
    @OverridepublicbooleanonEditorAction(TextView v, int actionId, KeyEvent event) {
        if (actionId == EditorInfo.IME_ACTION_DONE) {
            // set result in second edit text returntrue;
        }
        returnfalse;
    }
});

Solution 3:

Here you can add TextWatcher for input EditText like this,

  input.addTextChangedListener(newTextWatcher() {
                @OverridepublicvoidbeforeTextChanged(CharSequence s, int start, int count, int after) {

                }

                @OverridepublicvoidonTextChanged(CharSequence s, int start, int before, int count) {


                    // Check some Validations and Conditions here// Convert function goes here if all validationand conditions checked
                    convert();

                }

                @OverridepublicvoidafterTextChanged(Editable s) {

                }
            });

Hope it will help you my friend !

Post a Comment for "How To Get A Result Data To Edit Text Without Clicking On Button?"