android-databinding

Unresolved reference: BR (Android Studio)

我的未来我决定 提交于 2019-12-21 07:35:27
问题 My top level build.gradle: buildscript { ext.kotlin_version = '1.2.41' ext.lifecycle_version = "1.1.1" repositories { google() jcenter() } dependencies { classpath 'com.android.tools.build:gradle:3.1.3' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } } My project level build.gradle: android { ... dataBinding { enabled = true } } dependencies { ... implementation fileTree(dir: 'libs', include: ['*.jar']) implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin

Android 2-Way DataBinding With Custom View and Custom Attr

此生再无相见时 提交于 2019-12-21 04:28:17
问题 I've been using 2-way databinding for a basic application, it was going pretty well, until i start with custom views and attrs. I want to create a custom view, with has a TextView and a EditText, and use it inside another layout: <TextView android:text="Holder" android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/tvTitle" android:layout_weight="1" /> <EditText android:layout_width="wrap_content" android:layout_height="wrap_content" android:inputType="none"

Live Data and 2-Way Data Binding: Custom setter not being called

风格不统一 提交于 2019-12-21 04:14:16
问题 I am using 2-way data binding to update a LiveData String object from my ViewModel with a string set in the EditText: <android.support.design.widget.TextInputEditText android:id="@+id/writeReviewTitle" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@={viewModel.liveReviewTitle}" /> So, from my understanding, the ViewModel would have its liveReviewTitle attribute updated every time the text changed in the EditText. I assume this is happening through the

Android Databinding build fail after Gradle plugin update with migration to annotationProcessor

杀马特。学长 韩版系。学妹 提交于 2019-12-21 03:58:19
问题 To support Instant Run in my version of Android Studio, I needed to upgrade my Gradle plugin from version 2.2.3 to 2.3.3 I'm aware I'm supposed to migrate to annoationProcessor and I believe I've followed that guide correctly after doing so, the Android DataBinding code generation fails The migration guide linked earlier states that all I need is to Make sure you are on the Android Gradle 2.2 plugin or newer Remove the android-apt plugin from your build scripts Change all apt, androidTestApt

How to bind method on RadioGroup on checkChanged event with data-binding

可紊 提交于 2019-12-20 09:59:32
问题 I was searching over the internet for how to perform the new cool android data-binding over the RadioGroup and I didn't find a single blog post about it. Its a simple scenario, based on the radio button selected, I want to attach a callback event using android data binding. I don't find any method on the xml part which allows me to define a callback. Like here is my RadioGroup: <RadioGroup android:id="@+id/split_type_radio" android:layout_width="match_parent" android:layout_height="wrap

Best practice for Android MVVM startActivity

让人想犯罪 __ 提交于 2019-12-20 08:56:12
问题 I am building an Android App using MVVM and DataBinding. And I have a function inside my ViewModel that starts an Activity. Is it okay to have an onClick call inside a ViewModel? Like this. public class MyViewModel { public void onClick(View view, long productId) { Context context = view.getContext(); Intent intent = new Intent(context, ProductDetailActivity.class); intent.putExtra("productId", productId); context.startActivity(intent); } } And in my XML: ... android:onClick="@{(v) ->

Android databinding on inner class not updating TextView

女生的网名这么多〃 提交于 2019-12-20 06:41:14
问题 App runs but the TextView doesn't get update here is the relevant code. activity_picker_dashboard.xml <android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent"> <!-- Top header --> <include layout="@layout/layout_header" /> This layout has databinding <!-- DrawerLayout --> <android.support.v4.widget.DrawerLayout android:id="

Cannot access activity binding android

纵饮孤独 提交于 2019-12-19 23:22:56
问题 I have a layout file called activity_suggestions . I am using databinding in it. Hence the file ActivitySuggestionsBinding got generated. The project compiles successfully. But when I try to run the project, I get this error e: error: cannot access ActivitySuggestionsBinding I am using android studio 3.1.2 with kotlin version 1.4.1 . Any help will be appreciated Edit Pasting my module level build.gradle and app level build.gradle Module Build.gradle apply plugin: 'kotlin-android' apply plugin

DataBindingUtil.setContentView(this, resource) return null

左心房为你撑大大i 提交于 2019-12-19 09:23:15
问题 I started using Android Data binding but without success.I have done everything as proposed in the documentation but when I have to set method value I get null. I am using Android Studio 2.1.2 and I put in gradle dataBinding { enabled = true } in layout I do exactly da same put layout and inside I put tag data: <data> <variable name="order" type="com.example.Order"/> </data> and in code when I want to have binding variable setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);

position of ViewPager item with Data Binding

让人想犯罪 __ 提交于 2019-12-19 08:13:48
问题 I have implemented ViewPager with use of android Data Binding, it is working perfect with data and click events. I have created interface for click event public interface ItemClickListener { public void onItemClick(); } Here is my instantiateItem() of PagerAdapter @Override public Object instantiateItem(ViewGroup container, final int position) { ListItemBinding binding = DataBindingUtil.inflate(mLayoutInflater, R.layout.list_item, container, false); binding.setHandler(itemClickListener);