在java中将加号变成字符串
所以我希望将加号存储为字符串并稍后显示到屏幕上;所以在这种情况下我有,
String plusSign = "+";
但是当我在屏幕上显示以上内容时,我得到一个奇怪的加号,周围有一个圆圈。我正在制作的应用程序中使用该变量,因此使用 android 可能与奇怪的格式有关。这是加号应该看起来的样子还是有办法让它看起来像普通的加号(没有圆圈的十字)?
让我添加一些我尝试过的替代方案。我做的第一件事是查看 unicode 版本的加号是否看起来有任何不同,但当我显示它时什么也没有出现(代码是 \u002B)。我也查看了 ascii 版本,但我不确定如何将其转换为字符串。
这是我用来在屏幕上显示字符串的代码,
Addition = new Text(PositionX, PositionY, standardFont, "Intergers" + plusSign + "Integers");
mScene.attachChild(Addition);
我使用 andEngine,所以这里是 Text 类 http://code.google.com/p/andengine/source/browse/src/org/anddev/andengine/entity/text/Text.java< /a>
看起来是这样与 android 相关: http://www. droidforums.net/forum/droid-x-faq/65474-what-those-icons.html
所以看起来如果你使用不支持某个字符的字体,它默认为安卓用什么。
So I want the plus sign to be stored as a string and displayed to the screen later; so in this case I have
String plusSign = "+";
but when I display the above on screen, I get a weird plus sign that has a circle around it. I am using the variable in an app that I'm making so using android may have something to do with the strange format. Is this how the plus sign is supposed to look or is there a way to make it look like a normal plus(a cross with no circle)?
Let me add some alternatives I've tried. The first thing I did was see if the unicode version of the plus sign would look any different but nothing appeared when I displayed it(the code was \u002B). I, also, looked at the ascii version but I wasn't sure how to convert it to a string.
Here is the code I use to display the string onScreen
Addition = new Text(PositionX, PositionY, standardFont, "Intergers" + plusSign + "Integers");
mScene.attachChild(Addition);
I use andEngine, so here is the Text class http://code.google.com/p/andengine/source/browse/src/org/anddev/andengine/entity/text/Text.java
It looks like it is related to android: http://www.droidforums.net/forum/droid-x-faq/65474-what-those-icons.html
So it seems like if you use a font that does not support a certain character, it defaults to what ever android uses.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
在我看来,最有可能的罪魁祸首是你正在使用的字体。我会仔细检查加号在该字体中没有圆圈。还有另一个符号,“xor”符号 (
"\u2295"
),它是一个加号,周围有一个圆圈。我想不出为什么加号会被这个符号替换,但是您可以尝试专门显示这个字符,看看它是否看起来像您在使用的字体中看到的那样。It looks to me like the most likely culprit is the font you are using. I would double check that the plus symbol doesn't have a circle in that font. There is another symbol, the "xor" symbol (
"\u2295"
) that is a plus with a circle around it. I can't think of a reason why the plus symbol would be replaced with this symbol, but you might try displaying this character specifically to see if it looks like what you are seeing in the font you are using.