java - 如何在 Android 的 TextView 中显示 unicode 字符?

标签 java android unicode textview

这是我的 Activity :

et.addTextChangedListener(mTextEditorWatcher);


private final TextWatcher mTextEditorWatcher = new TextWatcher() {

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


    }

    public void onTextChanged(CharSequence s, int start, int before, int count)
    {
        String name =et.getText().toString();
        String a ="a";
        String b ="b";
        String c ="c";
        String d ="d";
        String e ="e";
        String f ="f";
        String g ="g";
        String h ="h";
        String a1 ="\u24B6";
        String b1 ="\u24B7";
        String c1 ="\u24B7";
        String d1 ="\u24B9";
        String e1 ="\u24BB";
        String f1 ="\u24BB";
        String g1 ="\u24BD";
        String h1 ="\u24BD";
        name =name.replaceAll(a,a1);
        name =name.replaceAll(b,b1);
        name =name.replaceAll(c,c1);
        name =name.replaceAll(d,d1);
        name =name.replaceAll(e,e1);
        name =name.replaceAll(f,f1);
        name =name.replaceAll(g,g1);
        name =name.replaceAll(h,h1);
        tv.setText(name);
    }

    public void afterTextChanged(Editable s)
    {
        et.removeTextChangedListener(this);

        et.addTextChangedListener(this);

    }
};

当在 edittext 中写入 a 或 b 或 c 时,在 textview 中显示空格,解决方案是什么 显示unicode? 请帮忙

最佳答案

你可以尝试这样做:

tv.setText(name).trim(); // the String.trim() method removes leading and trailing white spaces

关于java - 如何在 Android 的 TextView 中显示 unicode 字符?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38616655/

相关文章:

android - 如何确保 Android 应用程序可以在每台设备上运行

android - 滑动菜单 Activity 中的@ContentView

android - 如何有条件地在 AOSP 中设置默认属性

php - PHP 和 MySQL 中的 unicode 字符问题

c - Linux 中的当前语言环境如何影响在 C 代码中使用文件名?

java - 验证 Postscript 而不尝试打印它?

java - 在ANTLR4中处理自定义异常

perl - Padre:如何检查/检查 Unicode 字符串?

java - Swagger 生成的客户端代码无法调用 https 本地主机端点

java - 使用 CompletableFuture 时如何避免编译器警告关闭 OutputStream?