Back to project page interamap.
The source code is released under:
MIT License
If you think the Android project interamap listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.richso.interamap.adapter; /*w ww. j av a 2 s . co m*/ import android.app.Activity; import android.content.Context; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.*; import com.richso.interamap.R; import com.richso.interamap.item.Category; import java.util.ArrayList; /** * Created with IntelliJ IDEA. * User: nikolai * Date: 9/12/13 * Time: 5:18 PM * To change this template use File | Settings | File Templates. */ public class ImageAdapter extends ArrayAdapter<Category> { private Context context; private ArrayList<Category> data = new ArrayList<Category>(); private int layoutResourceId; private RecordHolder holder = null; public ImageAdapter(Context context, int layoutResourceId, ArrayList<Category> data) { super(context, layoutResourceId, data); this.context = context; this.data = data; this.layoutResourceId = layoutResourceId; } @Override public View getView(int position, View convertView, ViewGroup parent) { View row = convertView; if ( row == null ) { LayoutInflater inflater = ((Activity) context).getLayoutInflater(); row = inflater.inflate(layoutResourceId, parent, false); holder = new RecordHolder(); holder.txtTitle = (TextView) row.findViewById(R.id.categoryTitle); ImageView imageView = (ImageView) row.findViewById(R.id.categoryImage); // imageView.setLayoutParams(new LinearLayout.LayoutParams(85, 85)); // imageView.setScaleType(ImageView.ScaleType.CENTER_CROP); // imageView.setPadding(8, 8, 8, 8); // imageView.invalidate(); holder.imageItem = imageView; row.setTag(holder); } else { holder = (RecordHolder) row.getTag(); } Category item = data.get(position); holder.txtTitle.setText(item.getName()); holder.imageItem.setImageBitmap(item.getIcon()); return row; } @Override public Category getItem(int position) { return super.getItem(position); } public String getTitle(int position) { return data.get(position).getName(); } class RecordHolder { TextView txtTitle; ImageView imageItem; } }