Android - Multiple textviews in Listview
<p>I am populating a Listview (list.xml) with a textview (list_row.xml).</p>

<p>I need to add an additional textview to list_row.xml, which means I need to wrap them in a layout. However, I get a Textview ID error when I do this.</p>

<p>list_row.xml I need:</p>

<pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"&gt;

&lt;TextView android:id="@+id/nameTV"
android:textSize="14sp"
android:textStyle="bold"
android:textColor="#FFFF00"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/&gt;

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

<p>Main.xml</p>

<pre><code>public View GetView(int inPosition, View inConvertView, ViewGroup inParent) 
{
    View _row = inConvertView;

    if (_row == null) 
    {
        // Inflate Row
        Log.d(TAG, "Starting XML Row Inflation ... ");
        LayoutInflater inflater = (LayoutInflater) 
                cContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        _row = inflater.inflate(R.layout.list_row, inParent, false);
        Log.d(TAG, "Successfully completed XML Row Inflation!");
    }

    // Get item
    PropertiesAd _adProperty = GetItem(inPosition);

    // Get reference to TextView - country_name
    cAdName = (TextView) _row.findViewById(R.id.nameTV);

    //Set name
    cAdName.setText(_adProperty.toString());

    return _row;
}
</code></pre>

<p>For the sake of testing, I haven't added the second textview yet. I'm just trying to get this to work with the layout wrapper.</p>

<p>Everything works fine without the LinearLayout. But again, I will need it to add a second textview. Suggestions?</p>

<p>Thanks</p>

<p>ArrayAdapter:</p>

<pre><code>public class ArrayAdapterAd extends ArrayAdapter&lt;PropertiesAd&gt; 
{

private static final String TAG = "AdArrayAdapter";
private Context cContext;
private TextView cAdName;
private List&lt;PropertiesAd&gt; cAdList = new ArrayList&lt;PropertiesAd&gt;();

public ArrayAdapterAd(Context inContext, int inTextViewResourceId, List&lt;PropertiesAd&gt; inObjects) 
{
    super(inContext, inTextViewResourceId, inObjects);

    this.cContext = inContext; 
    this.cAdList = inObjects;
}


public int GetCount() 
{
    return this.cAdList.size();
}


public PropertiesAd GetItem(int inIndex) 
{
    return this.cAdList.get(inIndex);
}


public View GetView(int inPosition, View inConvertView, ViewGroup inParent) 
{
    View _row = inConvertView;

    if (_row == null) 
    {
        // Inflate Row
        Log.d(TAG, "Starting XML Row Inflation ... ");
        LayoutInflater inflater = (LayoutInflater) 
                cContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        _row = inflater.inflate(R.layout.ad_list, inParent, false);
        Log.d(TAG, "Successfully completed XML Row Inflation!");
    }

    // Get item
    PropertiesAd _adProperty = GetItem(inPosition);

    // Get reference to TextView - country_name
    cAdName = (TextView) _row.findViewById(R.id.ad_listTextView);

    //Set country name
    cAdName.setText(_adProperty.toString());

    return _row;
}
</code></pre>

<p>}</p>
