本文整理汇总了Java中com.zhy.adapter.recyclerview.base.ViewHolder类的典型用法代码示例。如果您正苦于以下问题:Java ViewHolder类的具体用法?Java ViewHolder怎么用?Java ViewHolder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ViewHolder类属于com.zhy.adapter.recyclerview.base包,在下文中一共展示了ViewHolder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCreateViewHolder
import com.zhy.adapter.recyclerview.base.ViewHolder; //导入依赖的package包/类
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType)
{
if (isEmpty())
{
ViewHolder holder;
if (mEmptyView != null)
{
holder = ViewHolder.createViewHolder(parent.getContext(), mEmptyView);
} else
{
holder = ViewHolder.createViewHolder(parent.getContext(), parent, mEmptyLayoutId);
}
return holder;
}
return mInnerAdapter.onCreateViewHolder(parent, viewType);
}
示例2: onCreateViewHolder
import com.zhy.adapter.recyclerview.base.ViewHolder; //导入依赖的package包/类
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType)
{
if (viewType == ITEM_TYPE_LOAD_MORE)
{
ViewHolder holder;
if (mLoadMoreView != null)
{
holder = ViewHolder.createViewHolder(parent.getContext(), mLoadMoreView);
} else
{
holder = ViewHolder.createViewHolder(parent.getContext(), parent, mLoadMoreLayoutId);
}
return holder;
}
return mInnerAdapter.onCreateViewHolder(parent, viewType);
}
示例3: getAdapter
import com.zhy.adapter.recyclerview.base.ViewHolder; //导入依赖的package包/类
private CommonAdapter getAdapter() {
return new CommonAdapter<Tip>(this,R.layout.item_layout,tips) {
@Override
protected void convert(ViewHolder holder, final Tip tip, int position) {
holder.setText(R.id.poi_field_id,tip.getName());
holder.setText(R.id.poi_value_id,tip.getDistrict());
holder.getView(R.id.item_layout).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
EventBus.getDefault().post(tip);
finish();
}
});
}
};
}
示例4: getAdapter
import com.zhy.adapter.recyclerview.base.ViewHolder; //导入依赖的package包/类
private CommonAdapter getAdapter() {
return new CommonAdapter<ListViewHoldier>(this,R.layout.item_listview_location,data) {
@Override
protected void convert(ViewHolder holder, final ListViewHoldier listViewHoldier, int position) {
holder.setText(R.id.rl_tv_name,listViewHoldier.title);
holder.setText(R.id.rl_tv_location,listViewHoldier.address);
holder.getView(R.id.rl_tv_subit).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// Intent intent = new Intent(mContext,NavigationActivity.class);
// intent.putExtra("value",listViewHoldier.lp);
// intent.putExtra("address",listViewHoldier.address);
// setResult(RESULT_OK,intent);
Tip tip = new Tip();
tip.setDistrict(listViewHoldier.address);
tip.setPostion(listViewHoldier.lp);
EventBus.getDefault().postSticky(tip);
finish();
}
});
}
};
}
示例5: convert
import com.zhy.adapter.recyclerview.base.ViewHolder; //导入依赖的package包/类
@Override
protected void convert(ViewHolder holder, final ResolveInfo resolveInfo, int position) {
holder.setImageDrawable(R.id.image_view_resolver_icon,
resolveInfo.loadIcon(mPackageManager));
holder.setText(R.id.text_view_resolve_display_name,
resolveInfo.loadLabel(mPackageManager).toString());
holder.getConvertView().setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (mOnResolveInfoListener != null) {
mOnResolveInfoListener.onResolveInfoClick(resolveInfo);
}
}
});
}
示例6: onActivityCreated
import com.zhy.adapter.recyclerview.base.ViewHolder; //导入依赖的package包/类
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
int[] intArray = getResources().getIntArray(R.array.colors);
list.clear();
for (int anIntArray : intArray) {
list.add(anIntArray);
}
commonAdapter = new CommonAdapter<Integer>(getActivity(), R.layout.item_coupon_dash_line, list) {
@Override
protected void convert(ViewHolder holder, Integer s, int position) {
CouponView couponView = holder.getView(R.id.couponView);
couponView.setBackgroundColor(s);
}
};
mRecyclerView.addItemDecoration(new RecyclerView.ItemDecoration() {
@Override
public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
super.getItemOffsets(outRect, view, parent, state);
outRect.set(dp2Px(6), dp2Px(6), dp2Px(6), 0);
}
});
mRecyclerView.setLayoutManager(new GridLayoutManager(getActivity(), 2));
mRecyclerView.setAdapter(commonAdapter);
}
示例7: onActivityCreated
import com.zhy.adapter.recyclerview.base.ViewHolder; //导入依赖的package包/类
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
int[] intArray = getResources().getIntArray(R.array.colors);
list.clear();
for (int anIntArray : intArray) {
list.add(anIntArray);
}
commonAdapter = new CommonAdapter<Integer>(getActivity(), R.layout.item_coupon_combination, list) {
@Override
protected void convert(ViewHolder holder, Integer s, int position) {
CouponView couponView = holder.getView(R.id.couponView);
couponView.setBackgroundColor(s);
}
};
mRecyclerView.addItemDecoration(new RecyclerView.ItemDecoration() {
@Override
public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
super.getItemOffsets(outRect, view, parent, state);
outRect.set(dp2Px(6), dp2Px(6), dp2Px(6), 0);
}
});
mRecyclerView.setLayoutManager(new GridLayoutManager(getActivity(), 2));
mRecyclerView.setAdapter(commonAdapter);
}
示例8: onCreateViewHolder
import com.zhy.adapter.recyclerview.base.ViewHolder; //导入依赖的package包/类
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType)
{
// Log.d("LoadMoreCommonAdapter","onCreateViewHolder");
if (viewType == ITEM_TYPE_LOAD_MORE)
{
ViewHolder holder;
if (mLoadMoreView != null)
{
holder = ViewHolder.createViewHolder(parent.getContext(), mLoadMoreView);
} else
{
holder = ViewHolder.createViewHolder(parent.getContext(), parent, mLoadMoreLayoutId);
}
return holder;
}
return super.onCreateViewHolder(parent, viewType);
}
示例9: convertItem
import com.zhy.adapter.recyclerview.base.ViewHolder; //导入依赖的package包/类
@Override
protected void convertItem(ViewHolder holder, final PlayBean playBean, int position) {
holder.setImageUrl(R.id.thumnails,playBean.thumb,new GlideRoundTransform(mActivity,5));
holder.setText(R.id.title,playBean.title);
holder.setText(R.id.tv_viewnum,playBean.view);
holder.setText(R.id.nickName,playBean.nick);
holder.setImageUrl(R.id.ic_head,playBean.avatar,new GlideCircleTransform(mActivity));
holder.getItemView().setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent =new Intent(mActivity, CommonLiveUI.class);
intent.putExtra("playBean",playBean);
getActivity().startActivity(intent);
getActivity().overridePendingTransition(R.anim.anim_slide_in_right,R.anim.anim_slide_out_left);
}
});
}
示例10: convert
import com.zhy.adapter.recyclerview.base.ViewHolder; //导入依赖的package包/类
@Override
public void convert(ViewHolder holder, ChatMessage chatMessage, int position)
{
holder.setText(R.id.chat_send_content, chatMessage.getContent());
holder.setText(R.id.chat_send_name, chatMessage.getName());
holder.setImageResource(R.id.chat_send_icon, chatMessage.getIcon());
}
示例11: convert
import com.zhy.adapter.recyclerview.base.ViewHolder; //导入依赖的package包/类
@Override
public void convert(ViewHolder holder, ChatMessage chatMessage, int position)
{
holder.setText(R.id.chat_from_content, chatMessage.getContent());
holder.setText(R.id.chat_from_name, chatMessage.getName());
holder.setImageResource(R.id.chat_from_icon, chatMessage.getIcon());
}
示例12: onCreateViewHolder
import com.zhy.adapter.recyclerview.base.ViewHolder; //导入依赖的package包/类
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
ItemViewDelegate itemViewDelegate = mItemViewDelegateManager.getItemViewDelegate(viewType);
int layoutId = itemViewDelegate.getItemViewLayoutId();
ViewHolder holder = ViewHolder.createViewHolder(mContext, parent, layoutId);
onViewHolderCreated(holder,holder.getConvertView());
setListener(parent, holder, viewType);
return holder;
}
示例13: onViewAttachedToWindow
import com.zhy.adapter.recyclerview.base.ViewHolder; //导入依赖的package包/类
@Override
public void onViewAttachedToWindow(RecyclerView.ViewHolder holder)
{
mInnerAdapter.onViewAttachedToWindow(holder);
if (isEmpty())
{
WrapperUtils.setFullSpan(holder);
}
}
示例14: onBindViewHolder
import com.zhy.adapter.recyclerview.base.ViewHolder; //导入依赖的package包/类
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position)
{
if (isEmpty())
{
return;
}
mInnerAdapter.onBindViewHolder(holder, position);
}
示例15: onBindViewHolder
import com.zhy.adapter.recyclerview.base.ViewHolder; //导入依赖的package包/类
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position)
{
if (isShowLoadMore(position))
{
if (mOnLoadMoreListener != null)
{
mOnLoadMoreListener.onLoadMoreRequested();
}
return;
}
mInnerAdapter.onBindViewHolder(holder, position);
}