FileDocCategorySizeDatePackage
ImageListAdapter.javaAPI DocAndroid 1.5 API3991Wed May 06 22:42:46 BST 2009com.android.im.app

ImageListAdapter

public class ImageListAdapter extends android.widget.BaseAdapter implements android.widget.ListAdapter
A general image list adapter.

Fields Summary
private final android.view.LayoutInflater
mInflater
private final List
mData
private final int
mItemViewId
private final int
mImageId
private final int
mTextId
private final boolean
mAreAllItemsSelectable
private final int
mSeparatorId
Constructors Summary
public ImageListAdapter(android.content.Context context, List data)

        this(context, data, R.layout.imglist_item, R.id.image, R.id.text, R.id.separator);
    
public ImageListAdapter(android.content.Context context, List data, int itemViewId, int imgId, int textId, int separatorId)

        mData = data;
        mItemViewId = itemViewId;
        mImageId = imgId;
        mTextId = textId;
        mAreAllItemsSelectable = !data.contains(null);
        mSeparatorId = separatorId;
        mInflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    
Methods Summary
public booleanareAllItemsEnabled()

        return mAreAllItemsSelectable;
    
public intgetCount()

        return mData.size();
    
public java.lang.ObjectgetItem(int position)

        return mData.get(position);
    
public longgetItemId(int position)

        return position;
    
public android.view.ViewgetView(int position, android.view.View convertView, android.view.ViewGroup parent)

        View v;
        if (convertView == null) {
            v = mInflater.inflate(mItemViewId, parent, false);
        } else {
            v = convertView;
        }
        setupView(position, v);
        return v;
    
public booleanisEnabled(int position)

        return mData.get(position) != null;
    
private voidsetupView(int position, android.view.View view)

        ImageView iv = (ImageView) view.findViewById(mImageId);
        TextView tv = (TextView)view.findViewById(mTextId);
        View separator = view.findViewById(mSeparatorId);

        if (!isEnabled(position)) {
            if (iv != null) {
                iv.setVisibility(View.GONE);
            }
            if (tv != null) {
                tv.setVisibility(View.GONE);
            }
            if (separator != null) {
                separator.setVisibility(View.VISIBLE);
            }
        } else {
            if (separator != null) {
                separator.setVisibility(View.GONE);
            }
            final ImageListItem item = mData.get(position);
            if (iv != null) {
                iv.setVisibility(View.VISIBLE);
                iv.setImageDrawable(item.getDrawable());
            }
            if (tv != null) {
                tv.setVisibility(View.VISIBLE);
                tv.setText(item.getText());
            }
        }