google-developer-training / android-basics-kotlin-cupcake-app

Apache License 2.0
103 stars 163 forks source link

Android Basics: Shared ViewModel #57

Closed hubberlw closed 10 months ago

hubberlw commented 2 years ago

URL of codelab https://github.com/google-developer-training / android-basics-kotlin-cupcake-app

In which task and step of the codelab can this issue be found?

  1. Setup click listeners using listener binding

Describe the problem In the layout xml files for fragment_flavor.xml and fragment_pickup.xml, the lines android:onClick="@{() -> flavorFragment.goToNextScreen()}" android:onClick="@{() -> pickupFragment.goToNextScreen()}" do not compile. "goToNextScreen() results in "Cannot find identifier".

Steps to reproduce?

  1. Go to...
  2. Click on...
  3. See error... Screenshot 2022-02-10 011439

Versions Android Studio version: API version of the emulator: Bumblebee 2021.1.1 Patch 1 Build # AI-211.7628.21.2111.8139111 on Feb 1, 2022

Additional information Include screenshots if they would be useful in clarifying the problem.

EleoXDA commented 2 years ago

Hello.

Do you have these lines in FlavorFragment.kt?

    fun goToNextScreen() {
        findNavController().navigate(R.id.action_flavorFragment_to_pickupFragment)
    }