Ali Habbash
Ali Habbash

Reputation: 797

make listview show only the first line of each item

i want to make a listview items show only one line with ... in the end when the string of the item is more then one line just like this

item 1 is very good.

i want to make it looks like this

item 1 ....

because the list view bounds will be at "is" So, I don't want to have only a one line I have a basic action bar activity with list view layout and the XML code is

<?xml version="1.0" encoding="utf-8"?>`
<ListView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">

Note that the items will be added dynamically.

Thanks

Upvotes: 2

Views: 1336

Answers (2)

Haji khan
Haji khan

Reputation: 1

Sir use below code in textveiw

android:textColor="@color/white"
android:background="@color/black"

Upvotes: 0

Dharmbir Singh
Dharmbir Singh

Reputation: 17535

Please add these two line on your textview of listview adapter item.

android:singleLine="true"
android:ellipsize="end"

singleLine is depricated so please use maxLines like

android:maxLines="1"
android:ellipsize="end"

Upvotes: 2

Related Questions