【发布时间】:2016-07-27 16:47:39
【问题描述】:
我有一个活动,我有这个 sn-p....
et = (EditText) findViewById(R.id.et);
tv = (TextView) findViewById(R.id.textView8);
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.trim());
在编辑文本中写入 a、b 或 c 时,在文本视图中显示空间
什么是解决方案?
【问题讨论】:
-
可能是使用的字体不支持使用的unicode字符?为了测试尝试不同的 unicode 字符。此外,我会使用
replace(char, char)而不是使用正则表达式的replaceAll(可能会导致 unicode 出现问题?)
标签: java android xml unicode trim