android-databinding

Android databinding: set default visibility in xml

元气小坏坏 提交于 2020-06-24 21:30:30
问题 I show items in recyclerview and use databinding . In xml layout I has such view: <include android:visibility="@{viewmodel.expandable ? View.VISIBLE : View.GONE}" bind:viewmodel="@{viewmodel}" layout="@layout/full_station_layout"/> It works well but I has one issue: while recyclerview initializing and bind items to views this layout flashes once on the screen although initial value viewmodel.expandable is false. So, I decided temporary hide this layout and tried using default -parameter in

LiveData not able to observe the changes

心不动则不痛 提交于 2020-06-17 04:15:46
问题 The bounty expires in 5 days . Answers to this question are eligible for a +50 reputation bounty. kgandroid wants to draw more attention to this question. I am updating a LiveData value from a DialogFragment in the ViewModel , but not able to get the value in Fragment. The ViewModel: class OtpViewModel(private val otpUseCase: OtpUseCase, analyticsModel: IAnalyticsModel) : BaseViewModel(analyticsModel) { override val globalNavModel = GlobalNavModel(titleId = R.string.otp_contact_title,

AndroidX SwipeRefreshLayout with DataBinding

久未见 提交于 2020-05-27 06:28:48
问题 I'm trying to implement swipe to refresh functionality using AndroidX library: androidx.swiperefreshlayout.widget.SwipeRefreshLayout My app is using Android Databinding therefore I'd like to use observable fields to control the state of this widget. In the past I've used AppCompat one - it has as since been deprecated. Before, I could access the fields in the following way: <android.support.v4.widget.SwipeRefreshLayout xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width=

Two way binding cannot resolve a setter

℡╲_俬逩灬. 提交于 2020-05-15 11:13:47
问题 I am trying to learn about data binding I have my CreditCardViewModel class which is bind in my fragment as follows public class CreditCardValidatorFragment extends Fragment { private CreditCardViewModel cardViewModel; private CcValidateFragmentBinding binding; @Nullable @Override public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { binding = DataBindingUtil.inflate(inflater, R.layout.cc_validate_fragment, container,

Two way binding cannot resolve a setter

独自空忆成欢 提交于 2020-05-15 11:10:56
问题 I am trying to learn about data binding I have my CreditCardViewModel class which is bind in my fragment as follows public class CreditCardValidatorFragment extends Fragment { private CreditCardViewModel cardViewModel; private CcValidateFragmentBinding binding; @Nullable @Override public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { binding = DataBindingUtil.inflate(inflater, R.layout.cc_validate_fragment, container,

Android Data Binding: Missing return statement in generated code when calling custom binding adapter more than once

馋奶兔 提交于 2020-05-14 17:36:30
问题 I am using the android data binding library and MVVM architecture. In the xml layout I define a variable named viewModel of type myViewModel. The layout has several TextInputEditText for which I used the following custom binding adapter: //makes the drawable_right of the TextView clickable @SuppressLint("ClickableViewAccessibility") @BindingAdapter("onDrawableRightClick") inline fun TextView.setOnDrawableRightClick(crossinline f: () -> Unit) { this.setOnTouchListener(View.OnTouchListener { _,

Android Data Binding: Missing return statement in generated code when calling custom binding adapter more than once

前提是你 提交于 2020-05-14 17:35:03
问题 I am using the android data binding library and MVVM architecture. In the xml layout I define a variable named viewModel of type myViewModel. The layout has several TextInputEditText for which I used the following custom binding adapter: //makes the drawable_right of the TextView clickable @SuppressLint("ClickableViewAccessibility") @BindingAdapter("onDrawableRightClick") inline fun TextView.setOnDrawableRightClick(crossinline f: () -> Unit) { this.setOnTouchListener(View.OnTouchListener { _,

How to use android databinding within a library

无人久伴 提交于 2020-05-13 06:08:27
问题 Is it possible to use Android DataBinding within a library project? I did create a library to be used for other people. Within this library I did use Android DataBinding. It did work on the same Android Studio project as a module, but when i install it to my local maven repo it wouldn't compile because of the generated files couldn't be found. As I checked the aar file, i couldn't find the generated databinding folder as well. The following error will be produced: error: cannot access

Can not remove generated DataBinding code

本小妞迷上赌 提交于 2020-05-12 11:57:26
问题 I used DataBinding in one of my classes CardRecicleViewAdapterTech.class , but I imported a library which does not support DataBinding and I switched to butter knife for that class. The problem is that when I run the project, Android Studio always generates a class binding related with CardRecicleViewAdapterTech.class and this causes a crash. The generated class is: CardViewTechBinding.java I have deleted that java file in Android Studio databinding folder, but its generated again and again

Possible reason for “Error:cannot generate view binders java.lang.NullPointerException”

扶醉桌前 提交于 2020-05-11 03:58:05
问题 I am using Android Studio for my Android projects. I faced an issue when builds crash with strange stacktrace, like this: Error:Execution failed for task ':app:compileDevDebugJavaWithJavac'. java.lang.RuntimeException: failure, see logs for details. cannot generate view binders java.lang.NullPointerException at android.databinding.tool.reflection.ModelMethod.isBoxingConversion(ModelMethod.java:155) at android.databinding.tool.store.SetterStore.isBetterParameter(SetterStore.java:946) at