Aviel Gross
Aviel Gross

Reputation: 9965

EditText - Get text from EditText while typing

I want to get the text into some String in my app while the user is typing in the EditText and use it to lively show it on the activity (in different View...) - Just like google's live/instant search works...

Upvotes: 12

Views: 10533

Answers (1)

Ali
Ali

Reputation: 2042

You are looking for TextWatcher:

    youredittext.addTextChangedListener(new TextWatcher()
    {
        @Override
        public void afterTextChanged(Editable mEdit) 
        {
            text = mEdit.toString();
        }

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

        public void onTextChanged(CharSequence s, int start, int before, int count){}
    });

Upvotes: 35

Related Questions