コード例 #1
0
        public override Android.Views.View GetView(int position, Android.Views.View convertView
                                                   , Android.Views.ViewGroup parent)
        {
            Com.Zhy.Adapter.Abslistview.Base.ItemViewDelegate <T> itemViewDelegate = mItemViewDelegateManager
                                                                                     .GetItemViewDelegate(mDatas[position], position);
            int layoutId = itemViewDelegate.GetItemViewLayoutId();

            Com.Zhy.Adapter.Abslistview.ViewHolder viewHolder = null;
            if (convertView == null)
            {
                Android.Views.View itemView = Android.Views.LayoutInflater.From(mContext).Inflate
                                                  (layoutId, parent, false);
                viewHolder = new Com.Zhy.Adapter.Abslistview.ViewHolder(mContext, itemView, parent
                                                                        , position);
                viewHolder.mLayoutId = layoutId;
                OnViewHolderCreated(viewHolder, viewHolder.GetConvertView());
            }
            else
            {
                viewHolder           = (ViewHolder)convertView.Tag;
                viewHolder.mPosition = position;
            }
            Jbox <T> box = (Jbox <T>)GetItem(position);

            Convert(viewHolder, box.Value, position);
            return(viewHolder.GetConvertView());
        }
コード例 #2
0
        public virtual void Convert(Com.Zhy.Adapter.Abslistview.ViewHolder holder, T item
                                    , int position)
        {
            int delegatesCount = delegates.Size();

            for (int i = 0; i < delegatesCount; i++)
            {
                Com.Zhy.Adapter.Abslistview.Base.ItemViewDelegate <T> delegate_ = delegates.ValueAt
                                                                                      (i);
                if (delegate_.IsForViewType(item, position))
                {
                    delegate_.Convert(holder, item, position);
                    return;
                }
            }
            throw new System.ArgumentException("No ItemViewDelegateManager added that matches position="
                                               + position + " in data source");
        }
コード例 #3
0
 public static Com.Zhy.Adapter.Abslistview.ViewHolder Get(Android.Content.Context
                                                          context, Android.Views.View convertView, Android.Views.ViewGroup parent, int layoutId
                                                          , int position)
 {
     if (convertView == null)
     {
         Android.Views.View itemView = Android.Views.LayoutInflater.From(context).Inflate(
             layoutId, parent, false);
         Com.Zhy.Adapter.Abslistview.ViewHolder holder = new Com.Zhy.Adapter.Abslistview.ViewHolder
                                                             (context, itemView, parent, position);
         holder.mLayoutId = layoutId;
         return(holder);
     }
     else
     {
         ViewHolder holder = ((Jbox <ViewHolder>)convertView.Tag).Value;
         holder.mPosition = position;
         return(holder);
     }
 }