Android getMaxEms() equivalent

334 Views Asked by At

My TextView has android:maxLines="1" and I am getting an input from another EditText and pass it into the TextView . The problem is that when the first word of the input is too long the TextView doesn't show anything.So I want it to show the first part of the word and then end with "...". I have tried this

    int maxEms = textName.getMaxEms();
    if (setName.length() >maxEms){
        String str= "";
        for (int i=0;i<maxEms-3;i++){
            str+=setName.charAt(i);
        }
        str += "...";   
        textName.setText(str);
    }else textName.setText(setName);

but Eclipse says that .getMaxEms() requires Android API level 16

   <TextView
        android:gravity="center_vertical"
        android:background="@drawable/text_view_1"
        android:maxLines="1"
        android:visibility="gone"
        android:textColor="@color/text_color"
        android:id="@+id/textSetName1"
        android:layout_width="match_parent"
        android:layout_height= "match_parent"
        android:textSize = "17sp"/> 
0

There are 0 best solutions below