0
所以我有一個回收站視圖適配器在我的MainActivity中設置。該適配器連接到我稱爲組的自定義對象的數組列表。回收站視圖適配器沒有反映變化
public static RecyclerView.Adapter groupsListAdapter;
public ArrayList<Group> myGroups;
//內主要的活性的onCreate
groupsListAdapter = new MyAdapter(myGroups);
在一個不同的活動,我將其通過的意圖更新此數組列表的內容,第一。
Intent groupCreationIntent = new Intent(MainActivity.this, NewGroupActivity.class);
groupCreationIntent.putExtra("groupsList",myGroups);
startActivity(groupCreationIntent);
然後在其他活動中更新它。
private ArrayList<Group> groups;
//在其他活動的onCreate方法
groups = (ArrayList<Group>) getIntent().getSerializableExtra("groupsList");
當回到以前的活動(第二個活動是用於輸入一些信息,並與我的數據庫同步的話)我運行此代碼。
問題是列表適配器沒有反映更改,一旦我返回到主要活動,沒有任何內容出現在我的列表中。我究竟做錯了什麼?
如果數組列表得到填充,那麼在獲得結果後,如果在主要活動上做了notifydataset更改的最後部分,那將會更好。 – Ahmed
你檢查了notifydatasetchange()沒有反映變化的其他職位? – Elltz