Reusable Components in Android
Learn how to create a layout that's going to be reused by other layouts to display data.
Creating layout fragment
Create a new fragment
class from the file menu by clicking the blank fragment
, and the class will look like the one below. After that, change the name of the activity from MainActivity.kt
to NewsActivity.kt.
Create a package called ui
, and inside it, create two packages called activities
and fragments.
Drag the MainActivity
class to the activities
package and the BreakingNews
Fragment
class to the fragment
package as illustrated below.
Get hands-on with 1200+ tech skills courses.