我试图在我的android应用程序中的edittext中记录按键次数,但即时通过一种方式来实现它。Android:按键笔画数
我认为TextWatcher是实现这一目标的方法,但目前没有任何工作。我是一个新手android开发人员,所以任何帮助非常感谢。
mainTextBlock.addTextChangedListener(keyCounter);
...
TextWatcher keyCounter = new TextWatcher() {
public void afterTextChanged(Editable s) {
keyCount++;
TextView keystrokeCount = (TextView)findViewById(R.id.keystrokeCount);
keystrokeCount.setText(keyCount);
}
public void beforeTextChanged(CharSequence s, int start, int count,
int after) {
}
public void onTextChanged(CharSequence s, int start, int before,
int count) {
}
};
每当我在主文本块中输入任何文本时,我都会收到强制关闭。我试图计算键盘输入,而不是编辑文本中的字符数量,否则它会相当直接...
非常感谢!
请从logcat发布错误 – 2011-01-31 22:51:44