我想问。我得到了像这样的字符串json响应
"Bank Danamon|Reksa Dana Insight Money Syariah"
我想在Android setText
中更改该字符串Bank Danamon
Reksa Dana Insight Money Syariah
这是我设置响应时的代码
txvSettlementName.setText(itemSettlement.getAccountName());
有办法吗? 感谢
答案 0 :(得分:0)
您必须将字符串拆分为
String str = "Bank Danamon|Reksa Dana Insight Money Syariah";
String[] separated = str.split("|");
separated[0]; // this will contain "Bank Danamon"
separated[1]; // this will contain " Reksa Dana Insight Money Syariah"
答案 1 :(得分:0)
String accountName = itemSettlement.getAccountName();
accountName = accountName.replace("|","\n");
txvSettlementName.setText(accountName);
此代码将直接用换行符|
替换字符\n
,您可以直接将其设置为TextView