EditText-键入时从EditText获取文本 [英] EditText - Get text from EditText while typing

查看:113
本文介绍了EditText-键入时从EditText获取文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在用户输入EditText时将文本放入应用程序中的某些String中,并使用它在活动中(在不同的View中)生动地显示它-就像google的实时/即时搜索作品一样...

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

推荐答案

您在寻找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){}
    });

这篇关于EditText-键入时从EditText获取文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆