0

edittext があります。英語の文字または単語がキーボードから挿入されたときにメッセージを表示したいのですが、どうすればよいですか?

4

3 に答える 3

1

http://developer.android.com/reference/android/text/TextWatcher.htmlを使用

于 2012-10-04T06:22:53.903 に答える
0

このようにしてください -

((EditText)findViewById(R.id.et_testo)).addTextChangedListener(new TextWatcher() {

public void afterTextChanged(Editable s) {

}

public void beforeTextChanged(CharSequence s, int start, int count,
        int after) {
    // TODO Auto-generated method stub

}

public void onTextChanged(CharSequence s, int start, int before,
        int count) {
    // TODO Auto-generated method stub
    Toast.makeToast(activity.this, s.toString(), Toast.Long).show();
}
});

TextWatcherをご覧ください

于 2012-10-04T06:26:50.500 に答える
0

TextWatcher を使用して EditText 内のテキストを監視し、TextWatcher の「onTextChanged」メソッドで英語の文字または単語が検出されるたびに、メッセージを表示できます。

例は次のとおりです

TextWatcher textWatcher = new TextWatcher() {

            public void beforeTextChanged(CharSequence s, int start, int count,
                    int after) {
            }

            public void onTextChanged(CharSequence s, int start, int before,
                    int count) {
                // or here
            }

            public void afterTextChanged(Editable s) {
                // Check for English Character or word here and show message
        };

        // Set listener on the original text field
        itemText.addTextChangedListener(textWatcher);

    }

それが役に立てば幸い!!!

于 2012-10-04T06:26:40.173 に答える