0

I have a problem with a textview in a listview.

So what I have is 3 textview on the side of each other to be displayed on a single line for an adapter of a listview

Here is the code of the adapter xml file

<TableLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content" 
    android:stretchColumns="1">
    <TableRow>
        <TextView
        android:id="@+id/station_name"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:gravity="left|center_vertical"
        android:textSize="18sp"
        android:layout_margin="8sp"/>  
         <TextView
        android:id="@+id/station_lines"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:gravity="right|center_vertical"
        android:textSize="18sp"
        android:layout_margin="8sp"/>  
         <TextView
        android:id="@+id/station_distance"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:gravity="right|center_vertical"
        android:textSize="18sp"
        android:layout_margin="8sp"/>  
    </TableRow>
</TableLayout>

Sometimes the text of the line is too long and so it is spilling out of the screen. What I want to do is that the text of is cutted if it is too long so that and stays inside the screen.

So basically I have something like this

<this text is too long> <text2> <te

And I want

<this text is to..> <text2> <text3>

Any idea how to do this?

Community
  • 1
  • 1
Nirgal
  • 1
  • Maybe this helps: [SO Question](http://stackoverflow.com/questions/3373790/end-the-ellipse-problem-with-textviews) – weeska Nov 04 '14 at 09:17

1 Answers1

0

Try android:ellipsize="end" in your xml or alternatively do it in code: http://developer.android.com/reference/android/widget/TextView.html#attr_android:ellipsize.

I've never tried it in a table view though and don't have access to my test project to test it for you so I'm not entirely sure it would work. If it doesn't work, let me know and I'll delete this answer.

kha
  • 19,123
  • 9
  • 34
  • 67