Android custom ArrayAdapter with custom object
<p>I am new for Android development. </p>

<p>I was trying to implement a custom <code>ArrayAdapter</code> to accept custom object in Android Studio.</p>

<p>I have referenced the source code from some tutorial, but my screen output was improper that the custom object only fill in the <code>TextView</code> which link with the <code>textViewResourceId</code> of <code>ArrayAdapter</code> , but not the custom object's properties fill in all <code>EditText</code> in the layout appropriately.</p>

<p>I tried to remove <code>textViewResourceId</code> parameter in the constructor of <code>ArrayAdapter</code> to fix the problem, but Android Studio returned error - <strong>You must supply a resource ID for a TextView</strong></p>

<p>I want the properties of custom object fill in all <code>EditText</code> and no error message be returned, can anyone give me a hint?</p>

<p>Here is my layout:</p>

<p><strong>row_layout.xml</strong></p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal" android:layout_width="match_parent"
android:layout_height="match_parent"&gt;

&lt;TextView
    android:id="@+id/row_id"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:visibility="gone"/&gt;

&lt;EditText
    android:id="@+id/row_no"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_weight="1"
    android:layout_margin="1dp"
    android:layout_gravity="center_horizontal"
    android:background="@color/colorWhite"/&gt;

&lt;EditText
    android:id="@+id/row_text"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_weight="1"
    android:layout_margin="1dp"
    android:layout_gravity="center_horizontal"
    android:background="@color/colorWhite"/&gt;


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

<p>Here is my custom object:</p>

<p><strong>Row.java</strong></p>

<pre><code>public class Row
{
    public int RowNo;
    public String RowText;

    public Row(int no, String text)
    {
        this.RowNo = no;
        this.RowText = text;
    }
}
</code></pre>

<p>Here is my custom ArrayAdapter:</p>

<p><strong>RowAdapter.java</strong></p>

<pre><code>public class RowAdapter extends ArrayAdapter&lt;Row&gt; {

    private final Activity _context;
    private final ArrayList&lt;Row&gt; rows;

    static class ViewHolder
    {
        EditText RowNo;
        EditText RowText;
    }

    public RowAdapter(Activity context, ArrayList&lt;Row&gt; rows)
    {
        super(context,R.layout.row_layout, R.id.row_id ,rows);
        this._context = context;
        this.rows = rows;
    }

    public View GetView(int position, View convertView, ViewGroup parent){
        ViewHolder holder = null;

        if(convertView == null)
        {
            LayoutInflater inflater = _context.getLayoutInflater();
            convertView = inflater.inflate(R.layout.row_layout,parent,false);

            holder = new ViewHolder();
            holder.RowNo = (EditText)convertView.findViewById(R.id.row_no);
            holder.RowText = (EditText)convertView.findViewById(R.id.row_text);

            convertView.setTag(holder);
        }
        else
        {
            holder = (ViewHolder) convertView.getTag();
        }

        holder.RowNo.setText(rows.get(position).RowNo);
        holder.RowText.setText(rows.get(position).RowText);

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

<p>Here is my Activity class:</p>

<p><strong>RowActivity.java</strong></p>

<pre><code>   @Override
    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);
        setContentView(R.layout.row_list_page);

        listView = (ListView)findViewById(R.id.list_view);

        ArrayList&lt;Row&gt; rows = new ArrayList&lt;Row&gt;();
        rows.add(new Row(1,"Test"));
        rows.add(new Row(2,"Test"));
        rows.add(new Row(3"Test"));

        RowAdapter adapter = new RowAdapter(this,rows);
        listView.setAdapter(adapter);
}
</code></pre>