Skip to content

Instantly share code, notes, and snippets.

@haydarai
Last active February 6, 2017 12:52
Show Gist options
  • Save haydarai/9d46046642edcdd766485d50601b8d7d to your computer and use it in GitHub Desktop.
Save haydarai/9d46046642edcdd766485d50601b8d7d to your computer and use it in GitHub Desktop.
List<Post> posts = ...; // Fill the list with initial data
PostAdapter adapter = new PostAdapter(this, posts); // Initialize the RecyclerView Adapter
recyclerView.setAdapter(adapter); // Set adapter to the RecyclerView
/**
* Running some operation that modify the `posts` list
**/
adapter.notifyDataSetChanged; // Notify the adapter that the `posts` list already changed,
// it can also substituted with `notifyItemInserted`,
// `notifyItemChanged`, `notifyItemRemoved`, etc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment