Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.a.adapter;
- import android.content.Context;
- import android.view.View;
- import android.view.ViewGroup;
- import android.widget.BaseAdapter;
- import android.widget.GridView;
- import android.widget.ImageView;
- import com.a.R;
- public class SalesGridView extends BaseAdapter {
- private Context mContext;
- // Constructor
- public SalesGridView(Context c) {
- mContext = c;
- }
- public int getCount() {
- return mThumbIds.length;
- }
- public Object getItem(int position) {
- return null;
- }
- public long getItemId(int position) {
- return 0;
- }
- // create a new ImageView for each item referenced by the Adapter
- public View getView(int position, View convertView, ViewGroup parent) {
- ImageView imageView;
- if (convertView == null) {
- imageView = new ImageView(mContext);
- imageView.setLayoutParams(new GridView.LayoutParams(85, 85));
- imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
- imageView.setPadding(8, 8, 8, 8);
- } else {
- imageView = (ImageView) convertView;
- }
- imageView.setImageResource(mThumbIds[position]);
- return imageView;
- }
- // Keep all Images in array
- public Integer[] mThumbIds = {
- R.drawable.round, R.drawable.princess,
- R.drawable.emerald, R.drawable.asscher,
- R.drawable.radiant, R.drawable.cushion,
- R.drawable.oval, R.drawable.pear,
- R.drawable.marquise, R.drawable.heart,
- R.drawable.trillion
- };
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement