android-databinding

Espresso test fails with java.lang.String cannot be cast to com.abc.events.databinding.SponsorDetailBinding

允我心安 提交于 2019-12-13 07:45:31
问题 I get this error when my espresso test runs with android databinding on the fragment layout. I dont see any crash when I use the app. Is there anyway I can avoid this? onCreateView method in fragment: @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment SponsorDetailBinding mBinding = DataBindingUtil.inflate(inflater, R.layout.fragment_sponsordetail, container, false); return mBinding.getRoot(); }

Android Databinding Adapter Null Pointer Exception

一曲冷凌霜 提交于 2019-12-13 03:37:48
问题 I'm trying to use Android Databinding in my Android app. I've an Object Outlet if I initialize the object without any data. Everything works fine. And all data are well collected. But, if I initialize the Object with data and passing it to the layout, it crashes the app with complains of Invoking Interface method on Null Views . This is my Layout file below: <?xml version="1.0" encoding="utf-8"?> <layout xmlns:android="http://schemas.android.com/apk/res/android"> <data> <import type="java

Data binding “error: cannot find symbol class Models”

冷暖自知 提交于 2019-12-13 03:06:18
问题 First, I need to acknowledge the clearly very similar but not duplicate issue here. None of the proposed solutions in that thread work. My application file structure is as follows: app java [mydomain].[myapplication] Models DataModel.java MainActivity.java res layout activity_main.xml content_main.xml my_inner_layout.xml My app build.gradle contains dataBinding { enabled = true } In MainActivity.java I have import [mydomain].[myapplication].Models.DataModel; public class MainActivity extends

Android get duplicate attribute on DataBinding feature

本小妞迷上赌 提交于 2019-12-12 23:31:44
问题 I'm novice on using android dataBinding feature, when i successful change one of activity to using dataBinding feature i get error for other activity and i can't find whats problem I get this error: Error parsing XML: duplicate attribute What does mean duplicate attribute ? which attribute? My Layout: <?xml version="1.0" encoding="utf-8"?> <layout xmlns:android="http://schemas.android.com/apk/res/android"> <data> <variable name="newChannelViewModel" type="com.pishguy.androidapplication

Binding expression results in error, but compiles/runs fine

别来无恙 提交于 2019-12-12 23:15:33
问题 I seem to be getting an error when creating binding expressions in Android Studio. The code seems to compile and run ok and the method is called, but I'm still left with an error in Android Studio. Am I missing something here? As far as the documentation is concerned I don't think I am. 回答1: Android Studio is following data binding implementation and may show warnings or errors where there is no problem. It should keep improving. 来源: https://stackoverflow.com/questions/42187405/binding

How to pass variable number of arguments to databinding adapter?

纵饮孤独 提交于 2019-12-12 16:38:57
问题 I have Spinner and some count of EditText at layout. I want to bind type of EditText to state of Spinner . I.e. for FLOAT state of Spinner input type of all EditText components must be changed to floating point numbers for INTEGER input type must be integer To achive this I define binding adapter below: @BindingAdapter(value = {"bind:selectedValueAttrChanged", "bind:relatedInputs"}, requireAll = false) public static void setMeasurementUnit(final Spinner spinner, final InverseBindingListener

android databinding in custom controls

霸气de小男生 提交于 2019-12-12 15:26:36
问题 In official android docs - there is some guidance how to use databinding in fragments and activities. However I have pretty complex picker with high ammount of settings. Something like: class ComplexCustomPicker extends RelativeLayout{ PickerViewModel model; } So my question is what method of the picker I need to override to be able use binding inside it and not seting/checking individual values like textfield, etc? And second question - how could I pass viewmodel to my picker in xml file, do

Android dataBinding - TextView not visible depending on a boolean value

為{幸葍}努か 提交于 2019-12-12 10:58:06
问题 I'm trying to make a TextView visible depending on when a boolean 's value is set to true and a LinearLayout 's visibility depending on the false value of the same boolean variable using dataBinding . The problem is that only LinearLayout 's visibility is set and not of the TextView 's although when I log the boolean 's value it's state is changing as per the control flow. Below is my code any help is much appreciated as I'm stuck with this since last night and sorry if this is a noob

Android cannot generate view binders com.sun.tools.javac.code.Symbol$CompletionFailure:

空扰寡人 提交于 2019-12-12 08:34:44
问题 I am getting error while trying to build ./gradlew clean build . Here is the error I'm getting. error: cannot generate view binders com.sun.tools.javac.code.Symbol$CompletionFailure: class file for com.library.main.BaseViewModel not found BaseViewModel is a class that is in my library module used via maven dependency. I can see the class being included in dependency tree from external library explorer. Here is the stacktrace for build error. * Exception is: org.gradle.api.tasks

Android DataBinding - How to Bind A ViewGroup's Properties

久未见 提交于 2019-12-12 06:50:48
问题 I am developing an Android app in Xamarin.Android(C#). However, i do feel that this question can also be answered by any Java devs as well. I am new in android development. Anyways, i created a fragment with just a LinearLayout and a TextView inside it. When i create the background class for it, i don't inherit(on in JAVA's word, extend ) it from the Fragment class but rather from the LinearLayout class. So, the MyFragment.cs file starts like this : public class MyFragment : LinearLayout The