标签:
布局文件代码
<span style="font-size:18px;"><android.support.v7.widget.RecyclerView android:id="@+id/rv_PeiTaoPicHorizontal" android:layout_width="match_parent" android:layout_height="89dp" android:layout_marginBottom="16dp" android:layout_marginLeft="20dp" ></span>
<span style="font-size:18px;">public class PeiTaoXunJiaDetailRecyAdapter extends RecyclerView.Adapter<PeiTaoXunJiaDetailRecyAdapter.myViewHolder> { private Context context; private List arrayList; public PeiTaoXunJiaDetailRecyAdapter(Context context, List arrayList) { this.context = context; this.arrayList = arrayList; } @Override public myViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { myViewHolder holder = new myViewHolder(View.inflate(parent.getContext(), R.layout.activity_peitaoxunjiarecyitem, null)); return holder; } @Override public void onBindViewHolder(myViewHolder holder, int position) { } @Override public int getItemCount() { return arrayList==null ? 0 : arrayList.size(); } public class myViewHolder extends RecyclerView.ViewHolder { @Bind(R.id.iv_buchongPic) ImageView ivBuchongPic; public myViewHolder(View itemView) { super(itemView); ButterKnife.bind(itemView); } } }</span>主Activity代码
<span style="font-size:18px;">LinearLayoutManager linearLayoutManager=new LinearLayoutManager(this); linearLayoutManager.setOrientation(LinearLayoutManager.HORIZONTAL); rvPeiTaoPicHorizontal.setLayoutManager(linearLayoutManager); rvPeiTaoPicHorizontal.setAdapter(new PeiTaoXunJiaDetailRecyAdapter(getBaseContext(),arrayList));</span>
标签:
原文地址:http://blog.csdn.net/hzl9966/article/details/51395000