android-binding-adapter

Cannot find @BindindAdapter in dynamic feature module

[亡魂溺海] 提交于 2020-12-13 10:00:10
问题 I have extension function in app module @BindingAdapter("imageSrc") fun setImageUrl(view: ImageView, userId: Int) { try { val drawableRes = when { userId % 6 == 0 -> { R.drawable.avatar_1_raster } userId % 6 == 1 -> { R.drawable.avatar_2_raster } userId % 6 == 2 -> { R.drawable.avatar_3_raster } userId % 6 == 3 -> { R.drawable.avatar_4_raster } userId % 6 == 4 -> { R.drawable.avatar_5_raster } else -> { R.drawable.avatar_6_raster } } val requestOptions = RequestOptions() requestOptions

Android data binding - cannot find getter for <> that accepts parameter type 'long'

て烟熏妆下的殇ゞ 提交于 2020-06-28 02:51:17
问题 I have been using data binding for the past few weeks and now am trying to use a two way data binding for a custom view with a 'value' attribute. My problem is that I get the following error when building. Cannot find a getter for <com.twisthenry8gmail.dragline.DraglineView app:value> that accepts parameter type 'long' Now it was my understanding that the binding library will automatically use my public setters and getters however the most confusing part is adding a redundant inverse binding

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 { _,

Compiler error when applying theme with databinding

为君一笑 提交于 2020-04-18 05:42:14
问题 My code shuffles colors and indexes for a list of ColorBox objects indefinitely. This is my view: <TextView style="@style/App.WidgetStyle.ColorBox" android:text="@{item.id}" android:theme="@{item.theme}" tools:text="A" tools:theme="@style/App.ColorBox" /> My styles: <style name="App.WidgetStyle.ColorBox" parent="App"> <item name="android:layout_width">@dimen/square_size</item> <item name="android:layout_height">@dimen/square_size</item> <item name="android:background">@drawable/shape_for

Any way to do Android binding with Lombok accessors?

青春壹個敷衍的年華 提交于 2019-12-23 20:31:17
问题 I'm starting to play with Android binding. The standard (1-way) binding is to the point of being good enough for the people I hang out with. However, I find that I can't use Lombok accessors without a Could not find accessor error. Have you found a way around this, shy of manually writing getters and setters like some kind of Lombok-ignorant cavebeast? @Bindable @Getter @Setter private String stringField; //Must uncomment hand-coded accessors to compile! //public String getStringField() {

Why is this BindingAdapter not working in Kotlin?

 ̄綄美尐妖づ 提交于 2019-12-19 03:19:29
问题 I have a ViewModel with: val imageUrl = ObservableField<String>() My layout XML has: <ImageView ... app:url="@{viewModel.imageUrl}" .../> I have a BindingAdapters file with a top level function: @BindingAdapter("url") fun loadImage(view: ImageView, url: String?) { ... } I'm getting the following error: data binding error msg:Cannot find the setter for attribute 'app:url' with parameter type android.databinding.ObservableField<java.lang.String> on android.widget.ImageView. Any idea why this

BindingAdapter doesn't work with DataBinding

女生的网名这么多〃 提交于 2019-12-11 03:58:35
问题 I've got a button: <layout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:binding="http://schemas.android.com/tools"> <data> <variable name="vm" type="com.MyViewModel" /> </data> <Button binding:singleParameterString="test" binding:firstStringParameter="@{vm.userName}" .../> ... The BindingAdapter looks as follows: @BindingAdapter("binding:singleParameterString", "binding:firstStringParameter") fun setFormattedString(btn: Button, singleParameterString: String,

Cusom event attributes in android bindings app:onMyEvent

余生长醉 提交于 2019-12-10 17:49:41
问题 Is there any way to wire up custom onSomeEventListener to the attribute using binding library? Examples provided for onClick are simple and they all use 'on' prefix and single-method interface listeners, and what about 'add' prefix and more complicated scenarios? Imagine I want to use custom wire up logic on RecyclerView.addOnItemTouchListener, determining the child view was touched from SimpleOnItemTouchListener.onTouchEvent and passing it to my view model, how can I achieve this? I want to

Android - Binding adapter not working

匆匆过客 提交于 2019-12-10 13:00:13
问题 I have create a binding adapter to display picture with picasso, but it doesn't work. I have the following error : Found data binding errors. ****/ data binding error ****msg:Cannot find the setter for attribute 'app:loadPicture' with parameter type java.lang.String on android.widget.ImageView. file:/home/groupevsc.com/mathieu_labar/Documents/Projects/android-jetpack/app/src/main/res/layout/activity_detail_movie.xml loc:27:31 - 27:52 ****\ data binding error **** Here is my binding adapter :