以下这段代码是如何实例化data并得到data数据的? private ListStudent data; public static StudentFragment newInstance return new StudentFragment; Override public View onCreateViewNonNull LayoutInflater
在onCreateView方法中,先实例化了一个空的LinkedList作为data的初始值,然后使用MyAdapter将data和item_student布局文件绑定起来,并设置RecyclerView的LayoutManager和Adapter。在点击addStudent按钮时,会跳转到AddStudentActivity页面,可以在该页面中添加新的Student对象并将其加入到data中,从而更新RecyclerView的数据。
原文地址: https://www.cveoy.top/t/topic/hphx 著作权归作者所有。请勿转载和采集!