EditText - 在输入时获取EditText中的文本

12
我希望在用户输入EditText时,获取文本并将其转换为字符串,并动态在活动中显示它(在不同的视图中...)- 就像Google的实时搜索一样...

3
http://mattgemmell.com/2008/12/08/what-have-you-tried/ - ruben
1个回答

34

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

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接