android-databinding

Use Tab layout in MVVM architecture with the data binding library

你离开我真会死。 提交于 2019-12-31 09:45:24
问题 I am developing an app that has tab layout as the image. I’d like to use MVVM architecture with data binding library but I am new with this framework. I can do this without using MVVM by normally setup tab layout using ViewPager as this sample. Normal tab layout without MVVM and data binding: activity_main.xml: <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width=

Android DataBinding in RecyclerView.ViewHolders with different layouts

若如初见. 提交于 2019-12-30 09:35:39
问题 I'm trying to use androids databinding feature in new project and so far very happy with it. But now i came across a problem in my recyclerviews viewholder. My viewholder uses different layouts (based on the viewtype when it gets created) public MediaViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { switch(viewType){ case HEADER: int layout = R.layout.item_media_header; break; case DEFAULT: int layout = R.layout.item_media_default; break; case SMALL: int layout = R.layout.item

android data binding <include> layout OnClick listener doesn't work

依然范特西╮ 提交于 2019-12-30 09:09:08
问题 I have a data binding layout that contains a frame layout with <include> of other layout inside: <FrameLayout android:id="@+id/global_actions_frame_layout" android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="0.075" android:background="@color/colorToolBar"> <include android:id="@+id/included" layout="@layout/global_actions"> </include> </FrameLayout> the layout has image buttons inside in this format: <ImageButton android:id="@+id/settingsButton" android

Error:Data Binding does not support Jack builds yet

谁说我不能喝 提交于 2019-12-30 08:05:31
问题 I am implementing DataBinding , it is working perfect, but it is not allowing me to use jackOptions . It throws error Data Binding does not support Jack builds yet while build. Here is my build.gradle android { defaultConfig { ... dataBinding { enabled true } jackOptions { enabled true } } compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } } 回答1: From yigit's comment it's clear that this functionality is still under development as he and

How to databind to onTextChanged for an EditText on Android?

孤街醉人 提交于 2019-12-28 03:45:08
问题 In Yigit Boyar and George Mount's talk on Android Databinding they illustrate how easy it is to bind to TextWatcher 's onTextChanged (at 13:41). On a Button. Are their slides wrong? First of all the Button View doesn't have an onTextChanged property. It neither has a setOnTextChanged method. Neither does EditText . But they both have addTextChangedListener which takes a TextWatcher as input. So what are they talking about? How do they do it? Their example code does not compile, but gives this

Data Binding class not generated

↘锁芯ラ 提交于 2019-12-27 10:45:40
问题 I am using Data Binding in my project, when using <layout> and <data> in my xml binding class is not generated. For example i have activity_main.xml <?xml version="1.0" encoding="utf-8"?> <layout xmlns:android="http://schemas.android.com/apk/res/android"> <data> </data> <RelativeLayout android:layout_width="match_parent" android:layout_height="match_parent"> </RelativeLayout> </layout> Now if i am writing ActivityMainBinding in my activity/fragment it shows error that class is not available.

Android data binding with include tag doesn't work

江枫思渺然 提交于 2019-12-25 04:21:35
问题 I'm using android data binding and it is working fine whenever I'm not using the include tag. If I included a view using the tag (even it is displaying on the app) but the data binding object doesn't recognize the views of the included layout. These are my layout files. internet_unavailable.xml <?xml version="1.0" encoding="utf-8"?> <layout xmlns:android="http://schemas.android.com/apk/res/android"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android

Viewbinding with error: incompatible with attribute android:visibility

折月煮酒 提交于 2019-12-25 03:26:34
问题 I'm trying to set the visibility and the src of an ImageView using data binding. I don't know why this error is showing up, and I truely believe that this was working at one point, but I could be wrong. Layout: <data> <import type="android.view.View" /> <import type="android.support.v4.content.ContextCompat" /> <variable name="viewData" type="com.myapp.SomethingViewData" /> </data> ... <ImageView ... android:src="@{ContextCompat.getDrawable(context, viewData.getIconResource())}" android

Optimizing Parent Fragment for ViewModel and DataBinding in order to avoid boilerplate code

天大地大妈咪最大 提交于 2019-12-25 01:47:17
问题 I have a ParentFragment and a ChildFragment . They are working pretty fine. My problem is that in the future I might create many child fragments and this makes me write this boilerplate code for every single child fragment. Thus, I would like to optimize my ParentFragment so that I do not have to write boilerplate code for every single new child framment I create in the future. ParentFragment abstract class ParentFragment<T: ViewDataBinding>: Fragment() { @LayoutRes abstract fun

Espresso test aren't running after adding espresso-contrib library in gradle

不羁岁月 提交于 2019-12-24 16:15:02
问题 When I'm adding the androidTestCompile 'com.android.support.test.espresso:espresso-contrib:2.2.1' in the gradle and run an Espresso test, I get the following error: Testing started at 5:59 PM ... 02/08 17:59:58: Launching changeText_sameAct...() No apk changes detected since last installation, skipping installation of /Users/xxx/Documents/home/MasterDetails/app/build/outputs/apk/app-debug.apk $ adb shell am force-stop databinding.com.masterdetails No apk changes detected since last