android / architecture-samples

A collection of samples to discuss and showcase different architectural tools and patterns for Android apps.
Apache License 2.0
44.29k stars 11.62k forks source link

What is the need for a fragment #568

Open shangeethsivan opened 6 years ago

shangeethsivan commented 6 years ago

Branch - todo-mvp

I can't understand the use of a fragment here. The only use it see is that it is used to separate the view and the activity.

Should I always create a fragment to separate the view even if Im not needing a fragment.

https://github.com/googlesamples/android-architecture/tree/todo-mvp/todoapp/app/src/main/java/com/example/android/architecture/blueprints/todoapp/taskdetail

zung commented 6 years ago

when i add a fragment then it can't be compiled,

shangeethsivan commented 5 years ago

@florina-muntenescu any thoughts on the above question

Akashsri3bi commented 2 years ago

when i add a fragment then it can't be compiled,

Branch - todo-mvp

I can't understand the use of a fragment here. The only use it see is that it is used to separate the view and the activity.

Should I always create a fragment to separate the view even if Im not needing a fragment.

https://github.com/googlesamples/android-architecture/tree/todo-mvp/todoapp/app/src/main/java/com/example/android/architecture/blueprints/todoapp/taskdetail

Though the idea of using an activity seems easy but creating a fragment is much better in long term , because fragments can be removed and resused multiple places. Hope it helps