About viewbinding

I would like to ask about ViewBinding.

The official

 buildFeatures{
        viewBinding = true
    }

but it does not work.

Here is an example code.

Layout Code

    <com.google.android.material.floatingactionbutton.FloatingActionButton
        android:id="@+id/floatingActionButton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginEnd="24dp"
        android:layout_marginBottom="24dp"
        android:clickable="true"
        android:focusable="true"
        android:tint="@color/white"
        android:src="@drawable/ic_add"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent" />

Kotlin Code

val view = inflater.inflate(R.layout.fragment_list, container, false)

        view.floatingActionButton.setOnClickListener { }

Is there any solution to this problem? I don't know why it is not working.

Android studio Vierson4.1.2 Gradle Viesion 6.5



Read more here: https://stackoverflow.com/questions/66329041/about-viewbinding

Content Attribution

This content was originally published by Yoshitaka at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: