I am developing android apps so in that i want display the four lines of text in single text view. my Array list contain data like following
Customer Name : Nilesh
Customer Contact : 23230200
Customer City : Pune
but when I write code like following only last line was displayed from the array List
XML
<TextView android:id="@+id/kbpViewTvCustNm"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="4dp"
android:layout_marginLeft="8dp"
android:lines="4"
android:textIsSelectable="false" />
code
for (String details : list2)
{
custName.setText(details);
}
Use a StringBuilder to make your array 1 String and append linebreaks in between the individual Strings like this:
StringBuilder builder = new StringBuilder();
for (String details : list2) {
builder.append(details + "\n");
}
custName.setText(builder.toString());
<TextView
android:id="@+id/kbpViewTvCustNm"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_marginBottom="4dp"
android:layout_marginLeft="8dp"
android:lines="4"
android:textIsSelectable="false" />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With