3
以编程方式将新项目添加到recyclerview吗?
我仍在努力让自己了解recyclerview。我有一个arraylist,可用于初始化回收站视图。 如何设置适配器和layoutmanager的新项目添加到回收视图中? private void initData() { mItems = new ArrayList<String>(); for (int i = 0; i < ITEMS_COUNT; i++) { mItems.add("Item " + (i + 1)); } } private void initRecyclerView() { mRecentRecyclerView = (RecyclerView) findViewById(R.id.recentrecyclerView); mRecentRecyclerView.setHasFixedSize(true); mRecentLayoutManager = new LinearLayoutManager(this); mRecentRecyclerView.setLayoutManager(mRecentLayoutManager); mAdapter = new RecyclerView.Adapter<CustomViewHolder>() { @Override public CustomViewHolder …