View on GitHub

FunDapter

Simplify Adapter creation for your Android ListViews.

Download this project as a .zip file Download this project as a tar.gz file

FunDapter is a new approach to Android ListView Adapters.

Achieve more. Write less code. Fix less bugs. Simply declare which fields you want and apply behaviours to them.

After writing what was probably my 1000th ListView Adapter, I've realized that I was mostly wasting my time. All we really need in order to create an Adapter is a layout file and a dictionary of field definitions!

Getting Started:

BindDictionary<Product> prodDict = new BindDictionary<Product>(); 

String fields:

prodDict.addStringField(R.id.title, new StringExtractor<Product>() { 
    @Override 
    public String getStringValue(Product item, int position) { 
    return item.title; 
    } 
}).typeface(tfBold).visibilityIfNull(View.GONE); // Chain methods for additional behaviour

Image fields:

prodDict.addImageField(R.id.image, new StringExtractor<Product>() { 

    @Override 
    public String getStringValue(Product item, int position) { 
       return item.imageUrl; 
    } 
}, new ImageLoader() { 
    @Override 
    public void loadImage(String url, ImageView view) { 
    // INSERT IMAGE LOADER LIBRARY HERE 
    } 
});

Create the adapter:

FunDapter<Product> adapter = new FunDapter<Product>(this, prodList, 
    R.layout.product_list_item, prodDict);

Many more field types are supported! Get started