Created
December 28, 2017 11:05
-
-
Save Velmm/92ec3986f0f0f02018c1ef2358ea8317 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MainActivity extends AppCompatActivity { | |
private RecyclerView recyclerView; | |
private RecyclerViewAdapter recyclerViewAdapter; | |
private List<Movie> movieList; | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_main); | |
movieList = new ArrayList<>(); | |
recyclerView = (RecyclerView)findViewById(R.id.recyclerView); | |
recyclerViewAdapter = new RecyclerViewAdapter(movieList); | |
RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(this); | |
recyclerView.setLayoutManager(layoutManager); | |
recyclerView.setAdapter(recyclerViewAdapter); | |
prepareMovie(); | |
} | |
private void prepareMovie(){ | |
Movie movie = new Movie("Star Wars The Last Jedi",R.drawable.star_war); | |
movieList.add(movie); | |
movie = new Movie("Coco",R.drawable.coco); | |
movieList.add(movie); | |
movie = new Movie("Justice League ",R.drawable.justice_league); | |
movieList.add(movie); | |
movie = new Movie("Thor: Ragnarok",R.drawable.thor_ragnarok); | |
movieList.add(movie); | |
recyclerViewAdapter.notifyDataSetChanged(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment