EditText - Get text from EditText while typing

送分小仙女□ 提交于 2019-12-21 09:07:47

问题


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


回答1:


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


来源:https://stackoverflow.com/questions/15798380/edittext-get-text-from-edittext-while-typing

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!