android-databinding

Generated binding class that only takes a LayoutInflater as its sole argument

随声附和 提交于 2021-02-11 16:45:42
问题 The generated binding class from the Android Data Binding library has different versions of the inflate method: One that looks like the usual LayoutInflater.inflate method that takes a viewGroup and attachToRoot parameter, and one that only takes a LayoutInflater and nothing else. The documentation doesn't explain the difference between the two and unfortunately Android Studio doesn't let me step through the source code of inflate so that I could figure out which values it is using internally

Data binding - XML not updating after onActivityResult

非 Y 不嫁゛ 提交于 2021-02-10 13:15:49
问题 Updating ObservableField inside onActivityResult(..) of activity but not reflecting that value to XML . If I call executePendingBindings() it will work. But the issue is, there are a lot of ObservableField and for every variable, I need to call executePendingBindings() . Anyone knows how to solve this issue ? 回答1: In ViewDataBinding.java file, there is one method for requesting rebind protected void requestRebind() { if (mContainingBinding != null) { mContainingBinding.requestRebind(); } else

Data binding - XML not updating after onActivityResult

回眸只為那壹抹淺笑 提交于 2021-02-10 13:10:38
问题 Updating ObservableField inside onActivityResult(..) of activity but not reflecting that value to XML . If I call executePendingBindings() it will work. But the issue is, there are a lot of ObservableField and for every variable, I need to call executePendingBindings() . Anyone knows how to solve this issue ? 回答1: In ViewDataBinding.java file, there is one method for requesting rebind protected void requestRebind() { if (mContainingBinding != null) { mContainingBinding.requestRebind(); } else

App crash caused by data binding related to java.lang.Runnable android.databinding.ViewDataBinding.mRebindRunnable

时光毁灭记忆、已成空白 提交于 2021-02-09 08:59:22
问题 The exception is the following: java.lang.NullPointerException: Attempt to read from field 'java.lang.Runnable android.databinding.ViewDataBinding.mRebindRunnable' on a null object reference at android.databinding.ViewDataBinding.access$100(ViewDataBinding.java:51) at android.databinding.ViewDataBinding$5.onViewAttachedToWindow(ViewDataBinding.java:142) at android.view.View.dispatchAttachedToWindow(View.java:14525) at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2836) at

App crash caused by data binding related to java.lang.Runnable android.databinding.ViewDataBinding.mRebindRunnable

痞子三分冷 提交于 2021-02-09 08:59:06
问题 The exception is the following: java.lang.NullPointerException: Attempt to read from field 'java.lang.Runnable android.databinding.ViewDataBinding.mRebindRunnable' on a null object reference at android.databinding.ViewDataBinding.access$100(ViewDataBinding.java:51) at android.databinding.ViewDataBinding$5.onViewAttachedToWindow(ViewDataBinding.java:142) at android.view.View.dispatchAttachedToWindow(View.java:14525) at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2836) at

How to databind livedata object (android)

感情迁移 提交于 2021-02-08 09:56:50
问题 Today I've some question about mvvm and databinding on android, I'm trying to bind object properties on view. I've an Object (Model) with some properties, by example : public String name; public String title; public int value; I've a ViewModel with livedata like this : MutableLiveData<Object> _obj = new MutableLiveData<>(); public LiveData<Object> obj = _obj; And, at last, I've a view like this : <layout> <data> <variable name="viewModel"> type="com.sample.app.viewmodels.MainViewModel" /> <

DataBinding templates for Android Studio?

不打扰是莪最后的温柔 提交于 2021-02-05 07:44:28
问题 I've decided to use DataBinding library for my Android project. Are there any plugins/code templates available to install into Android Studio to get new Activity / Fragment etc added using Android Studio's wizard auto generated code compatible with DataBinding? I need to create models/presenters/variables in xml every time, can I get them to be generated automatically? 回答1: you can ALT + Enter on your view root then convert into databinding layout . 回答2: Well,it's not fully what am I looking

How can I set a ConstraintLayout Group's visibility via DataBinding?

懵懂的女人 提交于 2021-01-29 10:49:43
问题 I have 2 Group s in my layout which control the visibility of my Views. However, I cannot set their visibility via DataBinding: <layout> <data> <import type="android.view.View"/> <variable name="viewModel" type="co.aresid.book13.fragments.trackinglist.TrackingListViewModel" /> </data> <androidx.constraintlayout.widget.ConstraintLayout> ... <androidx.constraintlayout.widget.Group android:id="@+id/content_group" android:layout_width="0dp" android:layout_height="0dp" android:visibility="@

Android Binding Adapter attribute not found

一个人想着一个人 提交于 2021-01-29 10:11:50
问题 I am using a binding adapter to have mutable text in one of my views. I believe I have it implemented correctly (and it's working in other places), but for the case of mutableText, it's getting the error AAPT: error: attribute mutableText not found I've looked through some other answers on here, but none of them have been able to solve the issue. Here is my layout file: <?xml version="1.0" encoding="utf-8"?> <layout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http:

How to use app:items=“@{viewModel.items}” attribute with RecyclerView, MVVM and data binding?

寵の児 提交于 2021-01-29 08:55:31
问题 There is an app:items="" attribute for RecyclerView, how is this attribute used with MVVM and android.arch.lifecycle.ViewModel , not ViewModel that extends BaseObservable? items could be LiveData, List or ObservableArrayList, with which collection should it be used? 来源: https://stackoverflow.com/questions/51078439/how-to-use-appitems-viewmodel-items-attribute-with-recyclerview-mvvm-and