我希望能够从另一个类中访问列表,然后将其放入我的
第一个包含列表的类。
第二个类从第一个类访问列表。
当我使用
RecyclerViewAdapter
对象中。第一个包含列表的类。
public class Class1 {
// The List :
List<Model1> mlisto = new ArrayList<>();
mlisto.add(new Model1("HOLA","Dep17",R.drawable.img));
mlisto.add(new Model1("bonjour","Dep17",R.drawable.img));
mlisto.add(new Model1("hi","Dep17",R.drawable.img));
}
第二个类从第一个类访问列表。
public class Class2 {
RecyclerViewAdapter adapter = new RecyclerViewAdapter(this,new Class1().mlisto);
}
当我使用
new Class1().mlisto
时,它返回一个空列表,RecyclerView
在应用程序中也没有显示任何内容。