该程序需要尽可能少的滞后。不幸的是,inputWord.setText("");
在下面的代码中给出了轻微的滞后。有没有办法绕过这个滞后?非常感谢您的帮助。
public void addInputWordListener(){
inputWord.addTextChangedListener(new TextWatcher() {
public void afterTextChanged(Editable s) {
if(s.toString().equals("")){
topView.setTextColor(Color.WHITE);
return;
}
if (s.toString().endsWith(" ")){ //submitting a word
token = s.toString().trim();
System.out.println("1");
if (token.equalsIgnoreCase(topView.getText().toString())){
System.out.println("2");
inputWord.setText("");
System.out.println("3");
topView.setText(midView.getText());
System.out.println("4");
midView.setText(botView.getText());
System.out.println("5");
botView.setText(MainMenu.we.nextWord());
System.out.println("6");
}else
{
topView.setTextColor(Color.RED);
}
}
}
public void beforeTextChanged(CharSequence s, int start, int count, int after) {}
public void onTextChanged(CharSequence s, int start, int before, int count) {}
});
}
以下是可疑运行的 LogCat 输出:
04-07 02:41:10.539: I/System.out(13152): 1
04-07 02:41:10.539: I/System.out(13152): 2
04-07 02:41:10.549: I/System.out(13152): 3
04-07 02:41:10.549: I/System.out(13152): 4
04-07 02:41:10.549: I/System.out(13152): 5
04-07 02:41:10.549: I/System.out(13152): 6