0
0
Android Kotlinmobile~10 mins

Navigation drawer in Android Kotlin - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to open the navigation drawer when the menu icon is clicked.

Android Kotlin
drawerLayout.[1](GravityCompat.START)
Drag options to blanks, or click blank then click option'
AopenDrawer
BcloseDrawer
ClockDrawer
DtoggleDrawer
Attempts:
3 left
💡 Hint
Common Mistakes
Using closeDrawer instead of openDrawer.
Using toggleDrawer instead of openDrawer.
2fill in blank
medium

Complete the code to set the navigation item selected listener for the drawer.

Android Kotlin
navigationView.[1] = this
Drag options to blanks, or click blank then click option'
AsetOnClickListener
BsetNavigationItemSelectedListener
CsetOnItemClickListener
DsetOnNavigationListener
Attempts:
3 left
💡 Hint
Common Mistakes
Using setOnClickListener which is for general clicks.
Using setOnItemClickListener which is for list views.
3fill in blank
hard

Fix the error in the code to properly close the drawer when an item is selected.

Android Kotlin
drawerLayout.[1](GravityCompat.START)
Drag options to blanks, or click blank then click option'
AcloseDrawer
BlockDrawer
CopenDrawer
DisDrawerOpen
Attempts:
3 left
💡 Hint
Common Mistakes
Using openDrawer instead of closeDrawer.
Using isDrawerOpen which only checks state.
4fill in blank
hard

Fill both blanks to check if the drawer is open and then close it.

Android Kotlin
if (drawerLayout.[1](GravityCompat.START)) {
    drawerLayout.[2](GravityCompat.START)
}
Drag options to blanks, or click blank then click option'
AisDrawerOpen
BcloseDrawer
CopenDrawer
DlockDrawer
Attempts:
3 left
💡 Hint
Common Mistakes
Using openDrawer instead of closeDrawer to close the drawer.
Not checking if the drawer is open before closing.
5fill in blank
hard

Fill all three blanks to create a map of menu item IDs to their titles from the navigation menu.

Android Kotlin
val menuMap = navigationView.menu.[1] { item ->
    item.[2] to item.[3]
}
Drag options to blanks, or click blank then click option'
Aassociate
BitemId
Ctitle
DforEach
Attempts:
3 left
💡 Hint
Common Mistakes
Using forEach which returns Unit, not a map.
Using wrong properties like 'itemTitle' or 'id' instead of 'title' and 'itemId'.