Questions tagged [android-databinding]

Data Binding Library to write declarative layouts and minimize the glue code necessary to bind your application logic and layouts. The Data Binding Library offers both flexibility and broad compatibility — it's a support library, so you can use it with all Android platform versions back to Android 2.1 (API level 7+).

Filter by
Sorted by
Tagged with
0 votes
2 answers
25 views

Android data binding generates Cannot Resolve Method

I'm trying to add databinding to my project according to Android Developers Official Documentation and I'm getting a 'Cannot resolve method' error for setUser. I'm getting really frustrated and ...
0 votes
0 answers
17 views

Android get variable in layout preview with data binding?

Is it possible to see in layout preview in Android Studio window an int in view's marginLeft? Here is what I'm trying: <data> <variable name="doorLeft" type=&...
  • 411
0 votes
0 answers
15 views

databind an ArrayList<SpannableStringBuilder> to TextView?

I'm trying to emulate a Wyse60 terminal in a TextView. My current design decodes the input stream in to an ArrayList<SpannableStringBuilder> before concatenating them all to a master ...
1 vote
0 answers
20 views

Is it possible to use style attribute as default value in databinding?

Do you know if it's possible to use theme attributes as default values for databinding? example: android:background="@{toolbarColors.backgroundColor, default=@color/color_primary}" ...
0 votes
0 answers
29 views

Problem in import statement of databinding

I cannot import databinding to my project. I enabled databinding and imported the databinding class in my kotlin code but I get unresolved error. I verified my build.gradle (:app) file and there is no ...
0 votes
0 answers
26 views

Understanding Data Binding in RecyclerView

I have a question the case I have I have a list of products linked in the recycleview Using DataBinding assigned in layout like this app:items="@{vm.items}" This Items object has the ...
0 votes
1 answer
39 views

Android: How to pass EditText's text property to DataBinding expression of another view

I have an EditText (@+id/quantityNumber) and a Button (@+id/addToCartButton) view next to each other in my layout. The EditText is a quantity field and the Button takes the value entered in the ...
  • 55
0 votes
0 answers
17 views

Databinding EditText.setText() doesn't work

I know that question were asked several times, but I can't get it working. EditText not gonna filled in onCreate(), onResume(), onPostResume(). override fun onCreate(savedInstanceState: Bundle?) { ...
  • 25
0 votes
0 answers
20 views

Kotlin data binding implementation for getting icons from API

As I am newbie to databinding in kotlin using Glide dependency. Please mention the step by step procedure for implementing the functionality. Any help would be greatly appreciated. Thank you!
  • 533
0 votes
1 answer
66 views

kotlin.UninitializedPropertyAccessException: lateinit property binding has not been initialized

my application is giving the below error that you mentioned above and it says there is an error on line 69, but you have tried all the solutions and could not fix it. You are new to programming and ...
  • 3
0 votes
1 answer
42 views

How to initialize preference datastore class in fragment to get saved data from login in kotlin?

as I'm new to kotlin and data store preference so I'm putting this question in a hope to get some proper way to do it.
0 votes
1 answer
20 views

Can databinding set the actual dp if available, otherwise fallback to resource in Android?

I have a TextView I want to set padding to it. For example it'll be paddingLeft. I want to allow some configuration on the padding but at the same time, if padding value is not provided, I want to ...
  • 3,421
0 votes
0 answers
8 views

is it possible to use databinding if xml is declared using merge block in Android?

I have an xml that I would want to use databinding. However, that xml is wrapped within merge block. When tried to put <data> under merge, the compiler gave me an error.
  • 3,421
0 votes
0 answers
27 views

set data binding null like view binding

One of our dear fellow android developer asked that Is it necessary to set ViewBinding to null in Fragment's onDestroy()? and the answer was yes. i don't use view binding per se, is use Data Binding ...
0 votes
0 answers
15 views

Dynamically connect parameter to view via DataBinding

Hi I have following Problem: Lets say I have multiple types of DataSets DataSet1{ @Bindable public String Name; @Bindable public int Duration; } DataSet2{ @Bindable ...
  • 113
0 votes
0 answers
33 views

Call Multiple Functions onClick

Is it possible to call multiple functions onClick with Lambdas and Data Binding? Right now I have android:onClick="@{()->ViewModel.doSomething()} when I would like to accomplish android:...
0 votes
0 answers
34 views

How to Enable DataBinding by default for new projects

is there any way to enable Data Binding by default for new project and also new activity or fragment we create ? I HOPE ?!! any advice you could give would be much appreciated .Thank You.
  • 21
1 vote
2 answers
85 views

Jetpack Compose - bind to an array of objects does not update UI

I am working on a project for writing an App with a chat messanger. I am using Firestore to store the messages. After loading the messages inside the app I am attaching snapshotListener which enable ...
0 votes
1 answer
115 views

Android databinding not triggered in jetpack compose android view

I am trying to mix Jetpack compose with some legacy code that we have. Was hoping that it would be an easy fix since this is a part of the app that is rarely used. The problem at hand is that i am ...
  • 1,342
0 votes
1 answer
27 views

How to arrange the text in 2 lines of Textview if it's value is received using databinding expression

As you can see in the code below I want the value in textview that has been set using databinding expression should be arranged in 2 lines after 22 digits in first line. Please help me to figure out ...
0 votes
1 answer
75 views

I want show a value from ViewModel to Textview in a fragment. Help me to do this

I want show "answerText.value" from MainViewModel to TextView in a fragment. MainViewModel: package com.example.intelligenttalkie import android.annotation.SuppressLint import android.view....
0 votes
2 answers
61 views

DataBindingUtil.setContentView | Not enough information to infer type variable T

When i use view binding it works fine but when i use data binding i receive errors My Imports : import android.os.Bundle import androidx.appcompat.app.AppCompatActivity import androidx.databinding....
2 votes
0 answers
40 views

when making a binding lib for xamarin android you need to adapt the functions with out parameters

I have a .jar library that I have added as EmbebedJar. Among them there is a function that returns an integer and asks for two parameters, a context and a list in which the readers are going to be ...
  • 155
0 votes
2 answers
48 views

In a Inventory - type Android App, I cannot display the room database

The app is in development and it can be found here: https://github.com/toaderDragos/GlycemicApp So, why can't I see the database? In the App inspection, the fields are populating but not showing. ...
0 votes
0 answers
29 views

How to disable the Connect button after the button clicked?

My OutPut is this Here, I'm using the 'connect' button in MainActivity and 'disconnect' button in MainFragment and create the Function for connect and disconnect in MainViewModel. Whenever I click ...
0 votes
1 answer
36 views

How does one remove the BACK arrow from the AppNavBar?

I've read a few lightly documented explanations of this on StackOverflow, but nothing that helps. What I've done is created a sample app with Navigation Drawer Activity using Android Studio that ...
  • 125
0 votes
1 answer
53 views

android two-way data binding for checkbox using int

I have a User data class as below and I need to use two-way data binding for the checkbox using the active variable. active == 1, check active == 0, uncheck data class User( var name: String, var ...
0 votes
2 answers
44 views

Recyclerview empty when changing data class

My app is working fine when using the data class that i'm currently using from an online exercise: https://android-kotlin-fun-mars-server.appspot.com/. But when I try to change it to my own data class ...
0 votes
2 answers
86 views

UninitializedPropertyAccessException: lateinit property binding has not been initialized

I am getting a random crash "lateinit property binding has not been initialized". Most of the time it's working fine but a few time randomly we are getting this crash on crashlytics. Please ...
0 votes
1 answer
49 views

BindingAdapter class not generated

I have implemented @BindingAdapters in many projects. Recently created a new project in Android Studio Dolphin. added plugin kotlin-kapt and other required dependencies. Not able to figure out what is ...
  • 122
0 votes
1 answer
135 views

<fragment> tag in XML and Databinding gives inflate exception

I am working on an existing project which uses DrawerLayout and a custom fragment for side navigation, but when I use data binding it gives inflate exception in XML file at <fragment> tag. Below ...
0 votes
2 answers
57 views

Change the color of the Recycler view item and return to the original state in kotlin

I have a Recycler view to display a custom calendar and everything works fine My problem is: when I click on one item, the color of the item changes, but when I click on another item, the previous ...
1 vote
0 answers
31 views

How to use Kotlin extension property of function type with Android data binding?

I defined a Kotlin extension property of function type: @set:BindingAdapter("myListener") var View.myListener: ((Boolean) -> Unit)? get() { // ... } set(value) { ...
  • 5,293
0 votes
1 answer
53 views

Databinding in recyclerView item doesn't work with the fragment viewModel

I have a recyclerView that shows a list of cart items, Every item is clickable and opens details fragment for that item, I'm Updating the item layout to have a delete button inside, the delete button ...
0 votes
0 answers
33 views

setTextColor() with Databinding it doesnt work

I've asked a similar question before, but this time I'm having trouble changing the text color. I can't understand why it's not working. What could be the problem? The code above works for progressbar ...
  • 123
0 votes
0 answers
22 views

Unable to access classes from CommonMain in databinding layout in Kotlin Mutliplatform Mobile project

In my Kotlin Mutliplatform Mobile project, in Android App side, I am using Databinding When I try to use a field (String) to bind them with a EditText from a class which is in commonMain module, I am ...
  • 1,024
0 votes
1 answer
21 views

Unresolved reference: layout

I got an error in my code while binding binding = DataBindingUtil.setContentView(this,R.layout.activity_main) in .layout I want to resolve this layout reference issue
1 vote
0 answers
44 views

onClick at XML can't see method from viewmodel using Room & databinding

It seems I have some problem with kapt. I study Android and try to create app with Room and Coroutines. I get this kind of mistakes: enter image description here and my onclicklistener at XML is ...
  • 11
0 votes
1 answer
83 views

Change color Progress indicator with Databinding?

I try all the ways but I can't change the color of progressbar. I tried to change it not only as binding but also in adapter but it doesn't work. Can you please help? ..... <com.google.android....
  • 121
0 votes
0 answers
16 views

Setting DatePicker date using DataBinding causing it to stop triggering OnDateChangedListener

I have a form activity in my app with a DatePicker. I'm using the MVVM architecture so I wanted to use DataBinding in order to link my UI elements to my ViewModel. It works fine for everything except ...
  • 824
0 votes
0 answers
38 views

databinding with TabLayout tabBackground

I have been trying to set the tabBackground of a TabLayout using databinding und binding adapter. Hier is my TabLayout xml: <com.google.android.material.tabs.TabLayout android:id="@+id/...
  • 311
0 votes
0 answers
21 views

ViewBinding generating an object of ViewDataBinding in Android

I have not enabled data binding in my project. And I don't even want to enable/use it. I have only View Binding enabled which I want to use. I have this layout file error_fragment.xml:- <?xml ...
-1 votes
1 answer
42 views

how to use data in every activity in android studio?

I am new to android studio. i am trying to make a app which is a simple guessing game. in this app every player will enter his name and two numbers. after every player submits their entries all ...
0 votes
0 answers
9 views

Databinding is initialized in improper order by automatically generated executeBindings

Preface I have a simple app with a viewmodel, a custom UI control, and a TextView. Databinding is setup like this: LiveData -> control.value -> control.preValue -> TextView When LiveData is ...
  • 355
0 votes
1 answer
212 views

Programmatically reuse layout with data binding

I have an xml layout consisting of textviews and an imageview showing User Profile and Location which I am getting from firebase (max 10). My main activity has a world map (fictional) as background. I ...
0 votes
0 answers
55 views

Access view binding from Google Maps Marker

I have an app using Google Maps and with multiple Marker on it. Each marker, use a custom layout. I am having trouble on 2 things. 1- how to access the view from the Marker when the callback: ...
  • 2,839
1 vote
0 answers
153 views

Android databinding not working on initial creation of view

Description First you need to know I have created a custom UI view which is basically a dial whose value you can change by dragging on it. preValue is the position of the dial at all times (in real-...
  • 355
0 votes
1 answer
338 views

Android studio doesn't generate layout preview when custom views with databinding are used

class SimpleView @JvmOverloads constructor( context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0 ) : ConstraintLayout(context, attrs, defStyleAttr) { init { val ...
  • 190
0 votes
1 answer
199 views

Android Kotlin: How to save an Int from a clickListener when using DataBinding?

I am trying to switch my code from working directly with my .xml file to working through Data Binding, but I am getting NumberFormatException even though I am using the .toInt(). This is the button I ...
  • 5
2 votes
3 answers
1k views

Pass Navigation fragments arguments to View Model class

I am new to android app development. Please help. I want to get navigation fragment arguments in my view model class directly. I am using data-binding. Here is my nav fragments argument <fragment&...
  • 23

1
2 3 4 5
50