带有ListView的android TextWatcher每次刷新

时间:2017-09-13 19:35:31

标签: android firebase textwatcher

每次更改实时数据库(firebase)时,我都会尝试在listview中突出显示行。它工作半正确,因为当我在位置“1”上改变某些东西时,它的突出显示正确,但接下来我改变了例如位置“2”,并且两个位置(1和2)都突出显示,等等。我在if语句中比较(当前对象字段与CharSequences)是不正确的,我想是的,但我不知道它是如何正确的。

public View getView(final int position, View convertView, final ViewGroup parent) {    
...
...
public void onTextChanged(CharSequence s, int start, int before, int count) {
            if ((user.name.equals(s.toString())) == false) {


                finalConvertView.setBackgroundColor(Color.GREEN);
                new CountDownTimer(500, 100) {

                    public void onTick(long millisUntilFinished) {

                    }

                    public void onFinish() {
                        finalConvertView.setBackgroundColor(Color.WHITE);

                    }
                }.start();

            }

        }

1 个答案:

答案 0 :(得分:0)

我通过添加finalConvertView.setBackgroundColor(Color.WHITE);

解决了这个问题 if语句与finalConvertView.setBackgroundColor(Color.GREEN);

之间的