I am developing a Cinema App, but I want to use 2 RecyclerViews, one has successfully loaded, it contains the list of cinemas, then I want when someone taps on any of the Cinemas it loads another list of RecyclerView containing Movies.
How can I deal with 2 RecyclerViews?
Am new in Android. Below is the link to the sample of codes:
This is the link of the sample codes
RecyclerView Item to Load Another RecyclerView with Nested JSON
You have to options here:
This will imply the data in the 2nd recylcler view need the ability to change multiple times.
Add this code in your onItemSelectListener from your cinemaRecyclerView
Cinema selectedCinema = cinemas.get(selectedPosition); // This is the selected cinema from the CinemaRecyclerView;
moviesAdapter.updateMovies(selectedCinema.getMovies);
In your MovieAdapter class add the following method.
public void updateMovies(List<Movie> movies){
this.movies.clear();
this.movies.addAll(movies);
notifyDataSetChanged();
}
Here you will need to pass the selected Cinema object to the next Activity/Fragment. Based on this selection you can directly instantiate your MoviesAdapter with the correct movies list.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.