简体   繁体   English

两个arraylist到一个recyclerview

[英]Two arraylist to one recyclerview

I have 2 Arraylists. 我有2个Arraylist。 One fetches SQLite data and one fetches Firebase Data 一种获取SQLite数据,另一种获取Firebase数据

What i want to do is display the sqlite Data first and then below that the Firebase data... My SQLite data is mostly old data and firebase data is new. 我想做的是先显示sqlite数据,然后在其下方显示Firebase数据...我的SQLite数据主要是旧数据,而Firebase数据是新数据。 So i want the new data to be showed first and then if i swipe up the old one. 因此,我希望先显示新数据,然后再向上滑动旧数据。 Can i add 2 lists to same recyclerviews as both fetches different types of data 我能否将2个列表添加到相同的recyclerviews中,因为两者均获取不同类型的数据

SQLite SQLite的

               while (csr.moveToNext()) {
                    String mA= csr.getString(csr.getColumnIndex(A));
                    String mB = csr.getString(csr.getColumnIndex(B));
                    String mC= csr.getString(csr.getColumnIndex(C));
                    String mD= csr.getString(csr.getColumnIndex(D));
                    String mE= csr.getString(csr.getColumnIndex(E));
                    String mF= csr.getString(csr.getColumnIndex(F));

                    list.add(new SQLiteHelper(mA, mV, mC, mD, mE, mF));

                }

Firebase 火力地堡

    Helper help= dataSnapshot.getValue(Helper.class);
    List.add(help);

Arraylist 1 = list (Old data) Arraylist 1 =列表(旧数据)

Arraylist 2 = List (New Data) Arraylist 2 =列表(新数据)

Can someone help me out please 有人可以帮我吗

You can just Create an Arraylist for the Adapter and then add the data you want to display first first and add the data you want to display below after that. 您可以只为适配器创建一个Arraylist,然后首先添加要显示的数据,然后再添加要在下面显示的数据。

List<Helper> sqlite = ...
List<Helper> firebase = ...

List<Helper> helpers = new ArrayList<>();
helpers.addAll(sqlite);
helpers.addAll(firebase);

//TODO pass list to the adapter

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM