Android Open Source - african-art-talent-discovery Photo Grid Adapter

From Project

Back to project page african-art-talent-discovery.


The source code is released under:

GNU General Public License

If you think the Android project african-art-talent-discovery listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.appsng.adapters;
// w  ww  .ja  va  2  s  .co m
import java.util.ArrayList;

import android.content.Context;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;

import com.appsng.models.Photo;
import com.ekoconnect.afriphotos.R;
import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.ImageLoaderConfiguration;

public class PhotoGridAdapter extends BaseAdapter {
    private static Activity activity;
    LayoutInflater inflater;
    SharedPreferences sharedPref;
  public ImageLoader imageLoader;
  public DisplayImageOptions iconOptions;
  ArrayList<Photo> photos = new ArrayList<Photo>();

  public PhotoGridAdapter(Activity a,ArrayList<Photo> photos) {
        activity = a;;

    sharedPref = PreferenceManager.getDefaultSharedPreferences(a);
        inflater = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    imageLoader = ImageLoader.getInstance();
    iconOptions = new DisplayImageOptions.Builder()

    public int getCount() {
        return photos.size();

    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder = null;
        if (convertView == null) {
             convertView = inflater.inflate(R.layout.adapter_grid_item, null);
                 holder = new ViewHolder();
                 holder.icon = (ImageView) convertView.findViewById(;
             holder = (ViewHolder) convertView.getTag();
    imageLoader.displayImage(photos.get(position).getUrl(),holder.icon, iconOptions);  

        return convertView;
  public Object getItem(int position) {
    // TODO Auto-generated method stub
    return null;
  public long getItemId(int position) {
    // TODO Auto-generated method stub
    return 0;

    class ViewHolder {
        ImageView icon;


Java Source Code List