Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2016
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. package com.a.adapter;
  2.  
  3. import android.content.Context;
  4. import android.view.View;
  5. import android.view.ViewGroup;
  6. import android.widget.BaseAdapter;
  7. import android.widget.GridView;
  8. import android.widget.ImageView;
  9.  
  10. import com.a.R;
  11.  
  12. public class SalesGridView extends BaseAdapter {
  13. private Context mContext;
  14.  
  15. // Constructor
  16. public SalesGridView(Context c) {
  17. mContext = c;
  18. }
  19.  
  20. public int getCount() {
  21. return mThumbIds.length;
  22. }
  23.  
  24. public Object getItem(int position) {
  25. return null;
  26. }
  27.  
  28. public long getItemId(int position) {
  29. return 0;
  30. }
  31.  
  32. // create a new ImageView for each item referenced by the Adapter
  33. public View getView(int position, View convertView, ViewGroup parent) {
  34. ImageView imageView;
  35. if (convertView == null) {
  36. imageView = new ImageView(mContext);
  37. imageView.setLayoutParams(new GridView.LayoutParams(85, 85));
  38. imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
  39. imageView.setPadding(8, 8, 8, 8);
  40. } else {
  41. imageView = (ImageView) convertView;
  42. }
  43.  
  44. imageView.setImageResource(mThumbIds[position]);
  45. return imageView;
  46. }
  47.  
  48. // Keep all Images in array
  49. public Integer[] mThumbIds = {
  50. R.drawable.round, R.drawable.princess,
  51. R.drawable.emerald, R.drawable.asscher,
  52. R.drawable.radiant, R.drawable.cushion,
  53. R.drawable.oval, R.drawable.pear,
  54. R.drawable.marquise, R.drawable.heart,
  55. R.drawable.trillion
  56.  
  57. };
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement