2013-04-17 48 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]