2017-11-20 4 views
0

私は配列リストからデータがロードされRecy​​clerViewを持っている:戻るボタンが第二の活動にタップするとonResume()の新しいデータでRecyclerViewをリフレッシュするには?私の主な活動で

protected void onReady(Bundle savedInstanceState) { 
    ... 
    // create summary item array & populate it based on task item array 
    _alData = new ArrayList(); 
    PopulateDataList(); 

    _rv = (RecyclerView) findViewById(R.id.rvDataList); 
    _li = getLayoutInflater(); 
    _rv.setLayoutManager(new LinearLayoutManager(this)); 

    _adapter = new TaskItemAdapter(); 
    _rv.setAdapter(_adapter); 
    ... 
} 

、それは私の主な活動に返しますが、RecyclerViewではありません新しいデータで更新されました。だから私は、次の追加したい:

public void onResume() { 
    super.onResume(); // Always call the superclass method first 

    // clear out & re-populate summary list, in case something has changed 
    _alData.clear(); 
    PopulateDataList(); 

    // *** WHAT GOES HERE...??? 
} 

私は再移植リストからデータを再バインドするRecyclerViewを伝える方法がわからない...任意の助けいただければ幸いです!

答えて

1

はpopulateDataList()の後にこれを追加します。

_adapter.notifyDataSetChanged(); 
+0

パーフェクト!それはかなり簡単でした。私はRecyclerViewでアダプタではなくいくつかのメソッドを探していました... –

関連する問題