Back to project page androidui.
The source code is released under:
MIT License
If you think the Android project androidui 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 course.examples.UI.TabLayout; /* w w w .j ava2 s .c om*/ import java.util.List; import android.content.Context; import android.view.View; import android.view.ViewGroup; import android.widget.BaseAdapter; import android.widget.GridView; import android.widget.ImageView; public class ImageAdapter extends BaseAdapter { private static final int PADDING = 8; private static final int WIDTH = 250; private static final int HEIGHT = 250; private Context mContext; private List<Integer> mThumbIds; public ImageAdapter(Context c, List<Integer> ids) { mContext = c; this.mThumbIds = ids; } @Override public int getCount() { return mThumbIds.size(); } @Override public Object getItem(int position) { return null; } // Will get called to provide the ID that // is passed to OnItemClickListener.onItemClick() @Override public long getItemId(int position) { return mThumbIds.get(position); } // create a new ImageView for each item referenced by the Adapter @Override public View getView(int position, View convertView, ViewGroup parent) { ImageView imageView = (ImageView) convertView; // if convertView's not recycled, initialize some attributes if (imageView == null) { imageView = new ImageView(mContext); imageView.setLayoutParams(new GridView.LayoutParams(WIDTH, HEIGHT)); imageView.setPadding(PADDING, PADDING, PADDING, PADDING); imageView.setScaleType(ImageView.ScaleType.CENTER_CROP); } imageView.setImageResource(mThumbIds.get(position)); return imageView; } }