当前位置: 首页>>代码示例>>Java>>正文


Java ViewHolder类代码示例

本文整理汇总了Java中com.mcxtzhang.commonadapter.rv.ViewHolder的典型用法代码示例。如果您正苦于以下问题:Java ViewHolder类的具体用法?Java ViewHolder怎么用?Java ViewHolder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ViewHolder类属于com.mcxtzhang.commonadapter.rv包,在下文中一共展示了ViewHolder类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onCreate

import com.mcxtzhang.commonadapter.rv.ViewHolder; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_rv_single);
    RecyclerView recyclerView = (RecyclerView) findViewById(R.id.activity_rv_single);
    recyclerView.setLayoutManager(new LinearLayoutManager(this));
    recyclerView.setAdapter(new CommonAdapter<TestBean>(this, mDatas = initDatas(), R.layout.item_test) {
        @Override
        public void convert(ViewHolder holder, TestBean testBean) {
            Glide.with(RvSingleActivity.this)
                    .load(testBean.getAvatar())
                    .into((ImageView) holder.itemView.findViewById(R.id.ivAvatar));
            ((TextView) holder.itemView.findViewById(R.id.tvName)).setText(testBean.getName());
        }
    });
}
 
开发者ID:mcxtzhang,项目名称:all-base-adapter,代码行数:17,代码来源:RvSingleActivity.java

示例2: onCreateViewHolder

import com.mcxtzhang.commonadapter.rv.ViewHolder; //导入依赖的package包/类
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    //add by zhangxutong 2016 08 05 begin ,for 点击事件为了兼容HeaderView FooterView 的Adapter
    if (null == mRv) {
        mRv = parent;
    }
    //add by zhangxutong 2016 08 05 end ,for 点击事件为了兼容HeaderView FooterView 的Adapter
    return ViewHolder.get(mContext, parent, viewType);
}
 
开发者ID:mcxtzhang,项目名称:all-base-adapter,代码行数:10,代码来源:BaseMulTypeAdapter.java

示例3: onCreate

import com.mcxtzhang.commonadapter.rv.ViewHolder; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_rv_header_mul_type);
    RecyclerView recyclerView = (RecyclerView) findViewById(R.id.rv);
    recyclerView.setLayoutManager(new LinearLayoutManager(this));

    mDatas = initDatas();
    mHeaderFooterAdapter = new HeaderFooterAdapter(new BaseMulTypeAdapter(this, mDatas) {
        @Override
        public void convert(ViewHolder holder, final IMulTypeHelper iMulTypeHelper) {
            super.convert(holder, iMulTypeHelper);

            switch (iMulTypeHelper.getItemLayoutId()) {
                case R.layout.item_rv_mulbean_1:
                    holder.setOnClickListener(R.id.tv, new View.OnClickListener() {
                        @Override
                        public void onClick(View view) {
                            MulTypeMulBean1 mulTypeMulBean1 = (MulTypeMulBean1) iMulTypeHelper;
                            Toast.makeText(mContext, mulTypeMulBean1.getName(), Toast.LENGTH_SHORT).show();
                        }
                    });
                    break;
                case R.layout.item_rv_mulbean_2:
                    holder.setOnClickListener(R.id.banner, new View.OnClickListener() {
                        @Override
                        public void onClick(View view) {
                            Toast.makeText(mContext, "你想调到哪里", Toast.LENGTH_SHORT).show();
                        }
                    });
                    break;
            }
        }
    });
    //1-0 同步静态数据,借助实体类
    mHeaderFooterAdapter.setHeaderView(0, new HeaderBean("1-0 同步静态数据,借助实体类 点我跳转到多Type界面"));
    recyclerView.setAdapter(mHeaderFooterAdapter);

}
 
开发者ID:mcxtzhang,项目名称:all-base-adapter,代码行数:40,代码来源:RvHeaderMulTypeActivity.java

示例4: onBind

import com.mcxtzhang.commonadapter.rv.ViewHolder; //导入依赖的package包/类
@Override
public void onBind(final ViewHolder holder) {
    holder.setText(R.id.tv, text);
    holder.setOnClickListener(R.id.tv, new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            //点击跳转到多ItemType
            holder.itemView.getContext().startActivity(new Intent(holder.itemView.getContext(), RvMulTypeMulBeanActivity.class));
        }
    });
}
 
开发者ID:mcxtzhang,项目名称:all-base-adapter,代码行数:12,代码来源:HeaderBean.java

示例5: convert

import com.mcxtzhang.commonadapter.rv.ViewHolder; //导入依赖的package包/类
@Override
public void convert(ViewHolder holder, T t) {
    t.onBind(holder);
}
 
开发者ID:mcxtzhang,项目名称:all-base-adapter,代码行数:5,代码来源:BaseMulTypeAdapter.java

示例6: onBind

import com.mcxtzhang.commonadapter.rv.ViewHolder; //导入依赖的package包/类
@Override
public void onBind(ViewHolder holder) {
    Glide.with(holder.itemView.getContext()).load(background).into((ImageView) holder.getView(R.id.banner));
}
 
开发者ID:mcxtzhang,项目名称:all-base-adapter,代码行数:5,代码来源:MulTypeMulBean2.java

示例7: onBind

import com.mcxtzhang.commonadapter.rv.ViewHolder; //导入依赖的package包/类
@Override
public void onBind(ViewHolder holder) {
    holder.setText(R.id.tv, name);
    Glide.with(holder.itemView.getContext()).load(avatar).into((ImageView) holder.getView(R.id.iv1));
    Glide.with(holder.itemView.getContext()).load(avatar).into((ImageView) holder.getView(R.id.iv2));
}
 
开发者ID:mcxtzhang,项目名称:all-base-adapter,代码行数:7,代码来源:MulTypeMulBean1.java

示例8: onBind

import com.mcxtzhang.commonadapter.rv.ViewHolder; //导入依赖的package包/类
void onBind(ViewHolder holder); 
开发者ID:mcxtzhang,项目名称:all-base-adapter,代码行数:2,代码来源:IMulTypeHelper.java


注:本文中的com.mcxtzhang.commonadapter.rv.ViewHolder类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。