android-databinding

Android DataBinding: can I pass constructor parameter to my data variable?

不羁的心 提交于 2019-12-24 06:03:56
问题 I have a MovieViewModel class that is used as variable in my layout file. <data> <variable name="vm" type="udacity.nanodegree.android.p2.model.comum.MovieViewModel"/>; </data> According with Android Data Binding docs: A special variable named context is generated for use in binding expressions as needed. The value for context is the Context from the root View's getContext(). The context variable will be overridden by an explicit variable declaration with that name. I need to pass this special

Error: Cannot find ActivitySplashBinding

耗尽温柔 提交于 2019-12-23 22:46:55
问题 I am trying to check that if user is logged on or not. If yes then show a specific view group otherwise show different view group. To check whether user is logged on or not I am fetching the user from shared preference (at the time of login user is saved in shared preference). Let me show my code. SplashViewModel public class SplashViewModel extends ViewModel { public final String TAG = "SplashViewModel"; private final String GREETING = "Hi "; public ObservableBoolean isLoggedIn = new

Android RecyclerView Adapter DataBinding - cannot find symbol {layout}BindingImpl

北城以北 提交于 2019-12-23 20:55:09
问题 I have a Fragment that displays a list of cities with weather informations. I am using a RecyclerView and I am trying to implement the Data Binding Library in my RecyclerView Adapter but for some reason I get this compile error : > error: cannot find symbol import com.example.zach.weatherapp.databinding.CityListItemBindingImpl; > ^ > symbol: class CityListItemBindingImpl > location: package com.example.zach.weatherapp.databinding It's an auto generated class so i really don't know where the

RuntimeException: view tag isn't correct on view:null on ViewAgendaItemBinding.bind() method

半世苍凉 提交于 2019-12-23 14:21:39
问题 I have pretty simple code which should be working according several articles regarding DataBinding but for some reason it's not. I'm trying to use RecycleView together with Databinding. class ItemViewHolder extends RecyclerView.ViewHolder{ ViewAgendaItemBinding binding; public ItemViewHolder(View itemView) { super(itemView); binding = ViewAgendaItemBinding.bind(itemView); //this is line where it's throw an error. } } I checked generated version of this bind method and it's looks like that:

Gradle Plugin 3.2.0 with databinding, can not resolve package name

Deadly 提交于 2019-12-23 12:15:05
问题 After updating Android Studio from 3.1.2 to 3.2.0, and updating the gradle plugin with it to 3.2.0, I am having a problem with a generated databinding classes which are complaining about a package name that does not exist, but it does exist. The package belongs to a module in the project. Here are the errors that I am getting when trying to run the app: error: cannot find symbol class Helper error: package Helper does not exist This is my project level build.gradle file: buildscript {

Cannot find the GETTER for attribute 'app:vm' with value type Boolean

流过昼夜 提交于 2019-12-23 09:58:31
问题 I'm trying to use native 2-way android data binding in my custom control so I have something like that in xml <layout> <data> <variable name="item" type="Boolean"/> </data> ... <my.control app:vm="@={item}"/> ... </layout> Please note, it's question about @={} - native 2 way binding. and something like that in code: class MyControl extends RelativeLayout{ ... @BindingAdapter("app:vm") public static void setVm(View v, VM vm){...} } My questions - how should I define getter for my viewModel? I

EditText LiveData Two-way binding

女生的网名这么多〃 提交于 2019-12-23 09:26:59
问题 Okay, so I have a ViewModel with a getter getTitle() that returns MutableLiveData<String> . <EditText style="@style/Widget.EditText.FullWidth" android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="@string/label_title" android:inputType="text" android:text="@={ viewModel.title }" /> This works fine at first: the EditText contains the value of the MutableLiveData when it first appears. However, if the value of this data is updated using MutableLiveData.setValue(

DataBinding is not working if setVariable() method is used to set ViewModel

删除回忆录丶 提交于 2019-12-23 05:27:57
问题 I have ParentFragment and ChildFragment . I am using Koin for DI. In one case, data binding is not working and in another it is working. NOT WORKING CASE: ParentFragment abstract class ParentFragment<T: ViewDataBinding, V: ParentViewModel>: Fragment() { @LayoutRes abstract fun getLayoutResId(): Int abstract fun init() protected lateinit var binding: T protected abstract val mViewModel: V override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?):

Android Databinding BindingAdapter Error

。_饼干妹妹 提交于 2019-12-23 04:23:31
问题 I am using following : public class BindingAdapter { @android.databinding.BindingAdapter({"app:eventName", "app:onClick"}) public static void setColorChangeListener(final View view, final String eventName, View.OnClickListener newListener) { CompositeClickListener c = new CompositeClickListener(); c.addOnClickListener(newListener); View.OnClickListener a = new View.OnClickListener() { @Override public void onClick(View v) { //Toast.makeText(view.getContext(), eventName, Toast.LENGTH_SHORT)

How DataBindingComponents works on per-layout basis? [duplicate]

孤街浪徒 提交于 2019-12-23 03:51:30
问题 This question already has an answer here : How do I access an instance variable inside a BindingAdapter when using Android Data Binding? (1 answer) Closed 2 years ago . Android DataBinding Library is a charming lib for me to learn MVVM. Now there's a problem, how to play an animation before update the text to the UI, on a per-layout basis . (Not a solution for global layouts using BindingAdapter , using a static binding adapter.) From the IO16 video I know perhaps I can use