2

My question is concerned to the next: my android app gets rather long strings from internet and places their into a ListView. Herewith current behaviour of ListView is such that strings are inserted in items completely that I see two or even more string in item. Can I change the ListView's behavior in such way to cause it to insert string in ListView something like that

"Long string is rather...."
"Long string is rather...."

changing the end of string, that doesn't fit to items, to three dots ?

Eugene Shmorgun
  • 1,891
  • 10
  • 39
  • 59

3 Answers3

6

set this to your TextView used as a row in List:

android:singleLine="true"
android:ellipsize="end"
waqaslam
  • 64,866
  • 15
  • 157
  • 170
2

yes you can do that. Fix the layout_width of the textView in XML property of the textView.

Say:

 <TextView
       android:id="@+id/text"
       android:layout_width="120dip"
       android:layout_height="wrap_content"
       android:text="text from server"
        android:singleLine="true"
       android:textColor="#ffffff"
       ></TextView>

In this way the text will be get adjust into that width accordingly (For example "Long string is rather...")

Dinesh Sharma
  • 14,278
  • 8
  • 41
  • 61
0

You can make it scroll if you use focus, however; with a listview this is going to be difficult because when should you request focus? Specifically you need to shrink your strings, simple a that. And set a max length on your ListView Items. So that they cap out at a certain length.

JoxTraex
  • 13,105
  • 5
  • 30
  • 45