我試圖在我的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