Search code examples
androidandroid-activityactivity-lifecycle

Android reutilizing Activity


I have 2 activities. A and B. A has a action bar with 4 items. Each item display a different list of movies. B extends A cause I want to be able to use the action bar to change the movie list.

So my question is, can I use the same instance of activity (B) to show the different movie lists when I press an item in the action bar ?

 Activity B

ACTIVITY B

 Activity A

ACTIVITY A


Solution

  • I think you are a bit over complicating it, you can use one activity ActivityA to have the actions (tabs) and the list (Recyclerview). When you click on a tab you update your list with the movies you want. Or you can create a Fragment to hold your movies list instead.

    Also I suggest that you use tabs instead of actionbar actions they are more user friendly and apply more to this case. If you go with the tabs you can have a Viewpager and you can swipe between your movie lists fragments. Here is all you need for the tabbed view