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タイプのオブジェクトです。EditTextから作成された文字列の文字数をTextViewにリアルタイムで表示したい。原理は単純で、私の考えでは完全に機能します(私がする必要があるのは、ソフトキーボードの文字を、そこで行ったのとまったく同じ方法で「インターセプト」することだけです)が、問題は次のとおりです。
http://developer.android.com/reference/android/view/inputmethod/EditorInfo.html
そのために利用できる定数はありません。これはおそらく、問題を解決するためにいくつかのあいまいなトリックを実行する必要があることを意味します。どうすればいいか知っていますか?