android - Set text programmatically from array -
i want set text programmatically array using single textview.i don't know whether possible or not.could give idea.
i want display this
hai,hello,what,where i need text should separate commas , in text-view
thanks in advance
i want set text programmatically array using single textview.i don't know whether possible or not.could give idea.
so can utilize stringbuilder or stringbuffer.
string[] array = {"one", "two", "three"}; stringbuilder builder = new stringbuilder(); for(string s: array) { builder.append(s + ","); // builder.append(s); } textview.settext(builder.tostring()); note: recommend utilize stringbuilder because strings immutable , work them much more memory-consume work stringbuilder or stringbuffer.
update:
for horizontal(one work 1 line) utilize \n so:
for(string s: array) { builder.append(+ "\n" + s + ","); // builder.append("\n"+ s); } case without stringbuilder:
string info = ""; for(string s: array) { info += "\n" + s + ","; // info += "\n"+ s; } android arraylist textview settext
No comments:
Post a Comment