如何从Edittext检索不同语言的字符串



我遇到了这个问题我怎么能检索字符串与另一种语言(不是英语)从编辑文本?

你应该能够简单地调用toString()在你的文本监视:

设置监听器:
name.addTextChangedListener(new GenericTextWatcher(name));

定义监听器:

private class GenericTextWatcher implements TextWatcher{
    private View view;
    private GenericTextWatcher(View view) {
        this.view = view;
    }
    public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {}
    public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {}
    public void afterTextChanged(Editable editable) {
        String text = editable.toString();
    }
}

字符串使用的语言应该无关紧要,除非您尝试存储或显示它。

最新更新