nameInput.setOnEditorActionListener(new OnEditorActionListener() {
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if (actionId == EditorInfo.????_?????_??????) {
Integer inputLength2 = nameInput.getText().length();
String realTimeText = inputLength2.toString();
textView1.setText("Number of Characters: " + realTimeText);
}
return false;
}
});
nameInput 是 EditText 类型的对象。我想在 TextView 上实时显示从 EditText 创建的字符串的字符数。原理很简单,在我看来它会很好地工作(我需要做的就是“拦截”软键盘的字符,就像我在那里所做的那样),但问题是:
http://developer.android.com/reference/android/view/inputmethod/EditorInfo.html
没有可用的常量,这可能意味着我需要做一些晦涩难懂的技巧来解决问题。你知道我该怎么做吗?