2013-04-17 44 views
5

我正在使用android。在我的项目中,我添加了'|'符号和符号“@”符号,但不添加@符号。我不是 得到我出错的地方。请帮我解决一下这个。如何将@符号添加到android中的字符串?

String str=""; 
str = str + "|" + id + "@" + id2 + "@" + id3; 

当我打印字符串“str”时,它只显示id值,但它不打印id1和id2。 输出: | 13

+0

字符串str = “”; str = str +“|” + 5 +“@”+ 7 +“@”+ 10; System.out.print(str); 输出:| 5 @ 7 @ 10 – Triode

+0

相同的字符串在我的设备中给出输出 – stinepike

+0

给定的字符串concat应该工作得很好。当涉及很多字符串连接时,我建议您使用StringBuilder。 – jaga

回答

0

使用此:

<string name="strings">\@Strings</string> 
0

我必须检查它像

String id = "A"; 
String id2 = "B"; 
String id3 = "C"; 

     String str=""; 
     str = str + "|" + id + "@" + id2 + "@" + id3; 

和输出像

|[email protected]@C 
0

我想这一点,

TextView tvAt = (TextView)findViewById(R.id.tvAtExample); 
String id1 = "A"; 
String id2 = "B"; 
String id3 = "C"; 
tvAt.setText(id1 + "|"+ id2 + "@" + id3); 

它的工作,它产生的输出

A|[email protected]