您好我要添加兩個RecyclerView
相同fragment
如圖所示,但我已經做了第一個recyclinglerview 。我沒有得到如何添加一個與我現有的代碼,請幫助我。我RecyclerView
代碼如何添加兩個recyclerview相同fragmnets
Communication.class
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_communication_summary, container, false);
mRecyclerView = (RecyclerView) view.findViewById(R.id.comm_expected_recycler_view);
mRecyclerView.setHasFixedSize(true);
mRecyclerView.setHasFixedSize(true);
mRecyclerViewLayoutManager = new LinearLayoutManager(getContext());
mRecyclerView.setLayoutManager(mRecyclerViewLayoutManager);
private class MyRecyclerViewAdapter extends RecyclerView.Adapter<MyRecyclerViewAdapter.ViewHolder> {
private List<CommunicationVO> mCommunicationVOsList;
public MyRecyclerViewAdapter(List<CommunicationVO> communicationVOsList) {
mCommunicationVOsList = communicationVOsList;
}
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.communication_summary_list_item, parent, false);
ViewHolder viewHolder = new ViewHolder(view);
return viewHolder;
}
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
if (holder != null) {
CommunicationVO communicationVO = mCommunicationVOsList.get(position);
holder.expInvoiceNumber.setText(communicationVO.getExpInvoiceNumber());
holder.expAmount.setText(CashPunditUtils.formatAmount(communicationVO.getExpAmount()));
holder.expDueDate.setText(CashPunditUtils.formatDate(CashPunditUtils.extractDateAndTime(communicationVO.getExpDueDate()), "dd-MMM-yy"));
holder.expPromisedDate.setText(CashPunditUtils.formatDate(CashPunditUtils.extractDateAndTime(communicationVO.getExpPromisedDate()), "dd-MMM-yy"));
}
}
@Override
public int getItemCount() {
return mCommunicationVOsList.size();
}
public class ViewHolder extends RecyclerView.ViewHolder {
public TextView expInvoiceNumber, expAmount, expDueDate, expPromisedDate;
public ViewHolder(View itemView) {
super(itemView);
expInvoiceNumber = (TextView) itemView.findViewById(R.id.textview_invnum);
expAmount = (TextView) itemView.findViewById(R.id.textview_amount);
expDueDate = (TextView) itemView.findViewById(R.id.textview_duedate);
expPromisedDate = (TextView) itemView.findViewById(R.id.textview_promisedate);
}
}
https://stackoverflow.com/questions/26245139/how-to-create-recyclerview-with-multiple-view-type –