user5083158
user5083158

Reputation:

Proper architecture of the android app (1 MainActivity and several Fragments)

I’m creating right now an android app with 1 MainActivity and several Fragments. It is advised to use an interface from Fragment which methods are overridden in MainActivity (http://simpledeveloper.com/how-to-communicate-between-fragments-and-activities/). But if I put all the logic of every Fragment inside of MainActivity, MainActivity will be very big with hundreds lines of code. Is it how it has to be? I doubt. What will you recommend?

Upvotes: 0

Views: 94

Answers (1)

Punit Vajpeyi
Punit Vajpeyi

Reputation: 206

Interfaces are mainly use to communicate between Activity and Fragment. So the main business logic of Fragment will be staying in fragment. You are just adding one function to communicate between fragment and Activity. So that wont be increasing the size of activity as such.

Upvotes: 1

Related Questions