我有 2 个适配器类及其对象类:
第一个适配器类是:
public class UpcomingAdpter extends RecyclerView.Adapter<UpcomingAdpter.ItemRowHolder> {
private ArrayList<UpcomingObject> itemList;
private Context context;
public UpcomingAdpter(ArrayList<UpcomingObject> itemList, Context context){
this.itemList = itemList;
this.context = context;
}
@Override
public ItemRowHolder onCreateViewHolder(ViewGroup viewGroup, int i) {
View v = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.upcominglayout, null);
ItemRowHolder mh = new ItemRowHolder(v);
return mh;
}
@Override
public void onBindViewHolder(ItemRowHolder itemRowHolder, int i) {
final String sectionName = itemList.get(i).getDate();
final ArrayList<SingleItemModelForUpcoming> singleSectionItems = itemList.get(i).getNamesList();
final ArrayList<SingleItemforPhoneNumbers> singleSectionItemsForPhoneNumber = itemList.get(i).getPhoneList();
itemRowHolder.date.setText(sectionName);
AdapterForNamesListInUpcoming itemListDataAdapter = new AdapterForNamesListInUpcoming(context, singleSectionItemsForPhoneNumber, singleSectionItems);
AdapterForNamesListInUpcoming itemListDataAdapterSecond = new AdapterForNamesListInUpcoming(context, singleSectionItemsForPhoneNumber, singleSectionItems);
itemRowHolder.recycler_view_list.setHasFixedSize(true);
itemRowHolder.recycler_view_list.setLayoutManager(new LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false));
itemRowHolder.recycler_view_list.setAdapter(itemListDataAdapter);
itemRowHolder.recycler_view_list.setAdapter(itemListDataAdapterSecond);
itemRowHolder.recycler_view_list.setNestedScrollingEnabled(false);
itemRowHolder.recycler_view_list.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Log.d("dd","here is me");
}
});
}
@Override
public int getItemCount() {
return (null != itemList ? itemList.size() : 0);
}
缥缈止盈
慕工程0101907
相关分类