SHARE
TWEET

Untitled

a guest Jun 25th, 2019 65 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public class ItemBaseAdapter extends BaseAdapter {
  2.  
  3.         Context context;
  4.         List<Item> list;
  5.  
  6.         ItemBaseAdapter(Context c, List<Item> l){
  7.             context = c;
  8.             list = l;
  9.         }
  10.  
  11.         @Override
  12.         public int getCount() {
  13.             return list.size();
  14.         }
  15.  
  16.         @Override
  17.         public Object getItem(int position) {
  18.             return list.get(position);
  19.         }
  20.  
  21.         @Override
  22.         public long getItemId(int position) {
  23.             return position;
  24.         }
  25.  
  26.         public List<Item> getList(){
  27.             return list;
  28.         }
  29.  
  30.         @Override
  31.         public View getView(int position, View convertView, ViewGroup parent) {
  32.             // TODO Auto-generated method stub
  33.             return null;
  34.         }
  35.     }
  36.  
  37.     public class ItemGridAdapter extends ItemBaseAdapter {
  38.  
  39.         ItemGridAdapter(Context c, List<Item> l) {
  40.             super(c, l);
  41.         }
  42.  
  43.         @Override
  44.         public View getView(int position, View convertView, ViewGroup parent) {
  45.             View gridrowView = convertView;
  46.  
  47.             // reuse views
  48.             if (gridrowView == null) {
  49.                 LayoutInflater inflater = ((Activity) context).getLayoutInflater();
  50.                 gridrowView = inflater.inflate(R.layout.criardeck, null);
  51.  
  52.                 GridViewHolder gridviewHolder = new GridViewHolder();
  53.                 gridviewHolder.carta = gridrowView.findViewById(R.id.imageViewCarta);
  54.                 gridrowView.setTag(gridviewHolder);
  55.             }
  56.  
  57.             GridViewHolder holder = (GridViewHolder) gridrowView.getTag();
  58.             holder.carta.setImageDrawable(list.get(position).ItemDrawable);
  59.  
  60.             gridrowView.setOnDragListener(new ItemOnDragListener(list.get(position)));
  61.  
  62.             return gridrowView;
  63.         }
  64.     }
  65.  
  66.     //items stored in ListView
  67.     public static class Item {
  68.         Drawable ItemDrawable;
  69.  
  70.         Item(Drawable drawable) {
  71.             ItemDrawable = drawable;
  72.         }
  73.     }
  74.  
  75. static class GridViewHolder {
  76.         ImageView carta;
  77.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top