Adding an custom EllipsizingTextView to a layout
<p>I came across the problem that android only supports ellipsizing a TextView with 2 lines. I found the solution here <a href="http://stackoverflow.com/questions/2160619/android-ellipsize-multiline-textview">android ellipsize multiline textview</a></p>

<p>However I'm now my textviews are getting displayed strangely, so instead of:</p>

<pre><code>This is a test...
</code></pre>

<p>My TextView dispalys</p>

<pre><code>This
is
a
</code></pre>

<p>Also the EllipsizingTextView seems to effect another TextView in the same layout which hasn't been declared to be a EllipsizingTextView but a regular TextView. Anyway here's the offending code:</p>

<pre><code>@Override
public View getView(int position, View itemView, ViewGroup parent) {
    View v = itemView;
    if (v == null) {
        LayoutInflater vi = (LayoutInflater)parent.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);

        v = vi.inflate(R.layout.list_item, null);
        LinearLayout layout = (LinearLayout) v.findViewById(R.id.linearLayout1);
        EllipsizingTextView desc = new EllipsizingTextView(parent.getContext());
        desc.setMaxLines(3);
        layout.addView(desc);
        ViewHolder vh = new ViewHolder();
        vh.label = (TextView) v.findViewById(R.id.label);
        vh.img = (ImageView) v.findViewById(R.id.img);
        vh.desc = (EllipsizingTextView) desc;
        vh.dateAdded = (TextView) v.findViewById(R.id.tvDateAdded);
        v.setTag(vh);
    }
</code></pre>

<p>And the XML:</p>

<pre><code>&lt;LinearLayout
    android:id="@+id/linearLayout1"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:layout_marginRight="0px"
    android:orientation="vertical" &gt;

    &lt;TextView android:text="@+id/TextView01" android:layout_width="fill_parent"
    android:layout_height="wrap_content" android:id="@+id/label"
    android:textSize="16sp" android:gravity="center_vertical" android:textColor="#000" android:singleLine="true"
    /&gt;
     &lt;TextView
        android:id="@+id/tvDateAdded"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textColor="#000"
        android:textSize="13sp"

        android:textAppearance="?android:attr/textAppearanceSmall" /&gt;

&lt;/LinearLayout&gt;
</code></pre>
