zoukankan      html  css  js  c++  java
  • ViewPagerAdapter

    package com.ali.fridge.supermarket.module;

    /**
    * Created by xiaomin.wxm on 2016/3/7.
    */

    import android.support.v4.view.PagerAdapter;
    import android.view.View;
    import android.view.ViewGroup;

    import com.ali.fridge.home.GoodsFragment;

    import java.util.List;


    public class ViewPagerAdapter extends PagerAdapter {

    private List<View> mList;
    private List<GoodsItem> mDataList;

    public ViewPagerAdapter(List<View> list, List<GoodsItem> dataList) {
    this.mList = list;
    this.mDataList = dataList;
    }

    @Override
    public int getCount() {
    if (mList != null && mList.size() > 0) {
    return mList.size();
    } else {
    return 0;
    }
    }

    @Override
    public boolean isViewFromObject(View arg0, Object arg1) {
    return arg0 == arg1;
    }

    @Override
    public void destroyItem(ViewGroup container, int position, Object object) {
    container.removeView((View) object);
    }

    @Override
    public Object instantiateItem(ViewGroup container, int position) {
    //container.removeView(mList.get(position));
    if (mList.get(position).getParent() != null) {
    ((ViewGroup) mList.get(position).getParent()).removeView(mList.get(position));
    }
    container.addView(mList.get(position));
    GoodsFragment.ViewHolder viewHolder = (GoodsFragment.ViewHolder) mList.get(position).getTag();
    if (mDataList.get(position).getNum() != null) {
    viewHolder.getNumView().setText((String) mDataList.get(position).getNum());
    }
    return mList.get(position);
    }

    @Override
    public int getItemPosition(Object object) {
    return POSITION_NONE;
    }

    }
  • 相关阅读:
    功能测试--电梯测试项
    进程
    基于UDP协议的socket编程
    自定义报头解决粘包问题
    基于TCP协议的socket编程
    python3 中encode 和decode的使用方法。
    反射---hasattr、getattr、setattr、delattr
    摘要算法---hashlib模块下MD5和SHA的使用
    日志模块---logging
    staticmethod、classmethod的使用
  • 原文地址:https://www.cnblogs.com/wxmdevelop/p/6347861.html
Copyright © 2011-2022 走看看