Questions tagged [android-viewbinding]

View binding is a feature that allows you to more easily write code that interacts with views. Once view binding is enabled in a module, it generates a binding class for each XML layout file present in that module. An instance of a binding class contains direct references to all views that have an ID in the corresponding layout. In most cases, view binding replaces findViewById.

View binding is a feature that allows you to more easily write code that interacts with views. Once view binding is enabled in a module, it generates a binding class for each XML layout file present in that module.

An instance of a binding class contains direct references to all views that have an ID in the corresponding layout.

In most cases, view binding replaces findViewById.

You can see this link for more.

482 questions
6
votes
3 answers

Suspicious indentation: This is indented but is not continuing the previous expression

Android studio showing me this issue with red line below my code line "Suspicious indentation: This is indented but is not continuing the previous expression (binding.cllInternetA...) (Previous statement here)" override fun onResume() { …
Assad khan
  • 161
  • 2
  • 9
6
votes
1 answer

View binding does not have access to fragment

I have an activity with ConstraintLayout and fragment on it:
Siarhei
  • 2,358
  • 3
  • 27
  • 63
6
votes
2 answers

How to Use View binding in SupportMapFragment?

How to use View binding in SupportMapFragment? ref my code I have a map fragment in the layout, I want to use view bind in the fragment. val mapFragment = childFragmentManager.findFragmentById(R.id.map) as SupportMapFragment Plz Need…
user15460872
6
votes
1 answer

View Binding with 2 possible layouts, assign binding variable to 2 generated binding classes

Desired functionality: I have an Activity that has a value received from backend which indicates to use either one of two layouts. Let's call this value layoutType and let's assume for simplicity in this example code below that we don't care how it…
Thanasis M
  • 1,144
  • 7
  • 22
6
votes
2 answers

Android View Binding - Unresolved Reference in Multi Module Project

Issue The Crypto Tweets sample app root branch implements Android View Binding for each of the three app modules, app, app-rx, and app-simple. All three modules run as expected. However, in the app and app-rx module, there are Lint errors for…
6
votes
1 answer

Are there any cons when using view binding rather than findViewById?

Since I discovered the use of view binding by enabling buildFeatures { viewBinding true } in my gradle file, I never used findviewById in my code again. I wonder now if there is a cons to doing things this way. If this is the best…
kfir88
  • 380
  • 2
  • 16
6
votes
0 answers

How much does the View Binding impact on the size of the app?

The View Binding, as specified by the documentation, generates a Binding class for each XML element, so as to facilitate access and inspection, as well as lighten the time load given by findViewById. While the findViewById acts through a more…
6
votes
0 answers

How does ViewBinding generate code in real time?

When i use ViewBinding, it always generate xxxxxBinding. I know android use Android Gradle Plugin build apk with code and resources。 And they're going to split some task (or transform). I know task(transform) will build some file into ./build . But…
6
votes
2 answers

Android 3.6 ViewStubProxy Unresolved reference

I have this Kotlin code: if(this.fragmentMeasurementBinding.viewStub.isInflated) { return; } this.fragmentMeasurementBinding.viewStub.viewStub?.layoutResource = …
5
votes
0 answers

Check your module classpath for missing or conflicting dependencies with gradle version 7.0.1

I Stuck with the problem. I have upgrade project grade to 7.0.1 and Kotlin 1.5.30. Before upgrading everything was working fine. But after upgrading, I am start getting the following error for each project. Even, I have tried to create new project…
Pushpendra
  • 1,492
  • 1
  • 17
  • 33
5
votes
2 answers

What is the difference between binding and _binding?

I am trying to understand the implementation of view binding in a fragment and I found that it is different from an activity. In an activity: private lateinit var binding: ResultProfileBinding override fun onCreate(savedInstanceState: Bundle?) { …
5
votes
0 answers

Execution failed for task ':app:dataBindingGenBaseClassesBetaDebug'

**Error : Execution failed for task ':app:dataBindingGenBaseClassesBetaDebug'. not a valid name: switch ** after updating android studio to version 4.2.1 unable to run build. buildFeatures { viewBinding true } ERROR Detail : FAILURE: Build…
Jithish P N
  • 1,970
  • 3
  • 26
  • 39
5
votes
4 answers

Android View Binding onClickListener not being called

I'm updating an app and I read that the recommended way to handle Views now is to use View Binding. I followed the instructions, however I'm having some problems: Adding a click listener with the following works: ((LinearLayout)…
someonewithpc
  • 366
  • 5
  • 14
5
votes
1 answer

AutoClearedValue accessed from another thread after View is Destroyed

I am using AutoClearedValue class from this link and when view is destroyed, backing field becomes null and that is good but i have a thread(actually a kotlin coroutine) that after it is done, it accesses the value(which uses autoCleared) but if…
mohsen sameti
  • 381
  • 1
  • 8
5
votes
3 answers

Android ViewBinding Error: Cannot access class 'android.widget.no_name_in_PSI_3d19d79d_1ba9_4cd0_b7f5_b46aa3cd5d40'

I tried to use ViewBinding in my Android Projects, because Kotlin synthetics are deprecated. I followed the official documentation from Android Developer's site. In my build.gradle.kts I enabled ViewBinding: android { ... buildFeatures { …
user10927125