A. The listener should be set with setOnClickListener instead
B. Using when instead of if-else is incorrect here
C. Missing return value for the lambda, causing a type mismatch error
D. The itemId values are invalid identifiers
Solution
Step 1: Check lambda return type requirement
The listener expects a Boolean return indicating if the tap was handled.
Step 2: Identify missing return statements
The when cases call functions but do not return true or false, causing a type mismatch.
Final Answer:
Missing return value for the lambda, causing a type mismatch error -> Option C
Quick Check:
Listener lambda must return Boolean [OK]
Hint: Always return true or false in setOnItemSelectedListener lambda [OK]
Common Mistakes:
Forgetting to return true after handling item
Using setOnClickListener instead of setOnItemSelectedListener
Ignoring compiler errors about return type
5. You want to create a BottomNavigationView with 4 items: Home, Search, Profile, and Settings. Which practice should you follow to ensure best usability?
hard
A. Use exactly 4 items and provide clear icons and labels for each
B. Add 6 items to show more options at once
C. Use only icons without labels to save space
D. Place the BottomNavigationView at the top of the screen