EditText - Get text from EditText while typing

后端 未结 1 1853
孤街浪徒
孤街浪徒 2021-02-20 08:59

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

1条回答
  •  爱一瞬间的悲伤
    2021-02-20 09:36

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

    0 讨论(0)
提交回复
热议问题