@@ -0,0 +1,1333 @@
+package com.activeandroid.widget;%0A%0Aimport java.util.List;%0A%0Aimport android.content.Context;%0Aimport android.widget.ArrayAdapter;%0A%0Aimport com.activeandroid.Model;%0A%0Apublic class ModelAdapter%3CT extends Model%3E extends ArrayAdapter%3CT%3E %7B%0A%0A%09public ModelAdapter(Context context, int textViewResourceId) %7B%0A%09%09super(context, textViewResourceId);%0A%09%7D%0A%0A%09public ModelAdapter(Context context, int resource,%0A%09%09%09int textViewResourceId) %7B%0A%09%09super(context, resource, textViewResourceId);%0A%09%7D%0A%0A%09public ModelAdapter(Context context, int textViewResourceId,%0A%09%09%09List%3CT%3E objects) %7B%0A%09%09super(context, textViewResourceId, objects);%0A%09%7D%0A%0A%09public ModelAdapter(Context context, int resource,%0A%09%09%09int textViewResourceId, List%3CT%3E objects) %7B%0A%09%09super(context, resource, textViewResourceId, objects);%0A%09%7D%0A%0A%09/**%0A%09 * Clears the adapter and, if data != null, fills if with new Items.%0A%09 * %0A%09 * @param data A List%3CT%3E which members get added to the adapter.%0A%09 */%0A%09public void setData(List%3CT%3E data) %7B%0A%09    clear();%0A%09    if (data != null) %7B%0A%09        for (T t : data) %7B%0A%09%09%09%09add(t);%0A%09%09%09%7D%0A%09    %7D%0A%09%7D%0A%0A%09/**%0A%09 * @throws RuntimeException If no record is found.%0A%09 * @return The Id of the record at position.%0A%09 */%0A%09@Override%0A%09public long getItemId(int position) %7B%0A%09%09T t = this.getItem(position);%0A%09%09if (t!=null)%0A%09%09%09return t.getId();%0A%09%09else%0A%09%09%09throw new RuntimeException(%22ItemNotfound%22);%0A%09%7D%0A%0A%7D%0A

Add ModelAdapter