简体   繁体   中英

How to print an item from list

I have a list. I want print list item horizontally with delimiter.

I got output like this:

OderHistory: Item1-1$
OderHistory: Item2-1$
OderHistory: Item3-1$

But i need like this:

OderHistory: Item1-1$Item2-1$Item3-1

Code here:

for(int i=0;i<itemList.size();i++){
  String name = itemList.get(i).ItemName;
  String quanty = itemList.get(i).Quantity;
  Log.d("OderHistory",name+"-"+quanty+"$");
}

Anyone help to me!

Thanks in advance...

Try this,

String result="";
for(int i=0;i<itemList.size();i++){
  String name = itemList.get(i).ItemName;
  String quanty = itemList.get(i).Quantity;
  result=result.concat(name+"-"+quanty+"$");
}
Log.d("OderHistory:",result);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM