android-databinding

Databinding variable inheritance with included layout

痞子三分冷 提交于 2019-12-08 16:21:06
问题 I am learning data binding and mvvm. I have an issue where I would like a BaseViewModel.kt to include some UI related variables such as an isLoading flag and loadingText . When a network request is made, I set isLoading to true and some child of my base view model should set the text. For example for a LoginViewModel.kt the text might be 'logging in'. Is it possible to pass these variables to an included base layout? So a login_activity.xml might include this in it's layout: <data> <import

Binding Adapter not working properly

a 夏天 提交于 2019-12-08 15:42:18
问题 I have a hard time making @BindingAdapter to work in my project. @BindingAdapter("imageUrl") public static void setImageUrl(ImageView imageView, String url) { Log.d("TEST","URL: " + url); } Above code shows how it is implemented in my ViewModel. Nothing special. <ImageView android:id="@+id/image_holder" android:layout_width="match_parent" android:layout_height="wrap_content" android:scaleType="centerCrop" android:layout_below="@id/profile_container" app:imageUrl="@{item.imageUrl}" tools:src="

Android : Databinding, notifyPropertyChanged() not working?

醉酒当歌 提交于 2019-12-08 14:52:25
问题 I am using Android's data binding library. I have my data object extending BaseObservable . public static class SimpleData extends BaseObservable implements Serializable { private String text, subText; private SpannableString totalText; @Bindable public SpannableString getTotalText() { return totalText; } public void setTotalText(SpannableString totalText) { this.totalText = totalText; notifyPropertyChanged(BR.totalText); } } And my xml is binded as well <TextView android:id="@+id/patient

The inflate method for my binding is not found (using Android, Data Binding.)

£可爱£侵袭症+ 提交于 2019-12-08 14:33:48
问题 I'm using data binding to bind the layouts in my Android app. I have set up my layout ( my_custom.xml ) and the binding class is generated (MyCustomBinding), but Android Studio does not seem to find the .inflate(...) method of the Binding class right away, marking it as an error ( red text!). The code seems to be correct though, since it compiles and builds just fine into an APK. How do I get Android Studio to update correctly ? Code example: This is my custom View code: public class

Android data binding attribute not found

若如初见. 提交于 2019-12-08 11:35:06
问题 I am trying to replicate this answer: Setting attribute of child element of included layout I have a simple custom_edit_text.xml : <?xml version="1.0" encoding="utf-8"?> <layout xmlns:android="http://schemas.android.com/apk/res/android"> <data> <variable name="hint123" type="String" /> </data> <android.support.design.widget.TextInputLayout android:id="@+id/emailInputLayout" android:layout_width="wrap_content" android:layout_height="wrap_content"> <android.support.v7.widget.AppCompatEditText

Two-Way Databinding not updating UI

。_饼干妹妹 提交于 2019-12-08 09:19:42
问题 I am trying to understand why setting a value does not automatically refresh the UI. If I call binding.setItem, the UI refreshes. I know binding object contains the updated values, but the UI is not being refreshed after setting item.name and item.checked. What am I doing wrong? Do I need to call setItem everytime to refresh the UI? I would think that this would be unnecessary, since the UI would automatically update after setting a value. Item.java: public class Item { public String name;

Obsfucation + Butterknife/Databinding

风格不统一 提交于 2019-12-08 05:57:55
问题 I currently use Butterknife to inject views into my code. I noticed class names are not obsfucated when i use minifyenabled, since butterknife needs the correct class name to generate the proxy classes that will do the binding. (MainActivity.class -> MainActivity_ViewBinding.class) I'm willing to switch to the "new" Data Binding Library in android studio. But since it's a lot of work considering my project is huge, here's my question: Will the Data Binding Library also not obsfucate the

Android Databinding: Possible to bind values from a HashMap

*爱你&永不变心* 提交于 2019-12-08 04:14:01
问题 I am binding to an Object's fields--strings, integers etc--to a layout file. For example: <data> <variable name="appState" type="com.example.app.AppState" /> </data> And <android.support.v7.widget.Toolbar android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" android:background="?attr/colorPrimary" android:title="@{appState.thing}" /> This works fine. However, I also have a HashMap of values in that appState object. Is it possible to bind to

Not work: Android Studio 3.2 Canary11 + 3.2.0-alpha11 for kapt with com.android.databinding

折月煮酒 提交于 2019-12-07 16:38:04
问题 Android Studio 3.2 Canary11 Gradle Tool 3.2.0-alpha11 com.android.databinding of kapt doesn't work with 3.2.0-alpha11, can not build / run apk. Meanwhile, it works max with 3.2.0-alpha10 ``` Execution failed for task ':app:kaptGenerateStubsDevDebugKotlin'. Could not resolve all files for configuration ':app:kapt'. Could not find com.android.databinding:compiler:3.2.0-alpha11. Searched in the following locations: file:/Users/xxxx/Library/Android/sdk/extras/m2repository/com/android/databinding

Imageview visibility by dynamic databinding

元气小坏坏 提交于 2019-12-07 12:57:49
问题 I want an imageView to be visible if internet connectivity is unavailable, invisible otherwise. How do I achieve this by dynamic data-binding ? Lets say, I have a function in my activity checkInternetConnectivity that returns true if internet connectivity is available. How do I dynamically bind the return value with the visibility of the imageView ? 回答1: You can use a custom attribute for the ImageView and invoke the method dynamically using Binding Adapter . XML <ImageView android:layout