Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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...

like image 616
Aviel Gross Avatar asked Apr 03 '13 21:04

Aviel Gross


1 Answers

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){}
    });
like image 93
NullPointer Avatar answered Nov 16 '22 01:11

NullPointer