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

问题描述:

这是我的活动:如何在Android中的TextView中显示unicode字符?

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); 

    } 
}; 

当写a或b或c在edittext表演空间textview什么解决 显示Unicode的? 请帮助

+0

请编辑您的问题,使代码是干净的没有像'''}'''而不是'''{''',并确保错误它正确缩进,因此它被呈现为“代码”给读者。 – raratiru

你可以尝试做:

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