databinding

DataBinding 官方文档翻译学习笔记

自作多情 提交于 2019-12-04 19:19:16
Data Binding Library 数据绑定库 This document explains how to use the Data Binding Library to write declarative layouts and minimize the glue code necessary to bind your application logic and layouts 本文介绍了如何使用数据绑定库去写声明布局文件和减少绑定你的应用程序的逻辑和布局所必需的粘合代码。 The Data Binding Library offers both flexibility and broad compatibility — it's a support library, so you can use it with all Android platform versions back to Android 2.1 (API level 7+). 数据绑定库是一个支持库,它提供了灵活性和广阔的兼容性,所以你可以在版本Android2.1之后的所有android平台中使用它。 To use data binding, Android Plugin for Gradle 1.5.0-alpha1 or higher is required. See how to update

Android Gradle 隐形依赖的奇怪案例

守給你的承諾、 提交于 2019-12-04 11:19:37
相信 Android 开发者都有在 Android Studio 中升级 compileSdkVersion 的经历,这个时候如果你使用了 support 包,并同时升级,那么可能会出现一个错误提示。本文教你如何解决这个问题。 在 Android Studio 中,Gradle 构建过程大多数都是抽象的。作为一个新手 Android 开发者,我们在使用 Gradle 的时候首先遇到的问题通常都是如何在 build.gradle 中添加远程依赖。 让我们来看一个情形并学习如何查看依赖树,以及解决依赖相关的问题。 我正在开发一个项目,并且我想把构建版本提升到最新的 API 27。同时,我把 build.gradle 中的 appcompat-v7 扩展库也升级到了 27.0.2.然后我 sync 项目,出现了如下错误: 所有的 com.android.support 库都必须使用相同的版本 这个错误说我必须使用完全相同版本的扩展包。很直接,但是我的 build.gradle 中只有这一个扩展包。Android Studio 在说什么呢? 😕上面提到的 com.android.support:animated-vector-drawable:27.0.2 和 com.android.support-v4:21.0.3 到底在哪? 如果只有 build.gradle

Obsfucation + Butterknife/Databinding

匿名 (未验证) 提交于 2019-12-03 10:24:21
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: 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 classes? Will switching from butterknife affect

ComboBox DataBinding causes ArgumentException

匿名 (未验证) 提交于 2019-12-03 08:46:08
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I several objects of class: class Person { public string Name { get; set; } public string Sex { get; set; } public int Age { get; set; } public override string ToString() { return Name + "; " + Sex + "; " + Age; } } and a class that has a property of type Person : class Cl { public Person Person { get; set; } } And I want to bind Cl.Person to combobox. When I try to do it like this: Cl cl = new cl(); comboBox.DataSource = new List<Person> {new Person{Name = "1"}, new Person{Name = "2"}}; comboBox.DataBindings.Add("Item", cl, "Person"); I get

WPF DataGrid - Databinding Column to Page&#039;s ViewModel

匿名 (未验证) 提交于 2019-12-03 08:46:08
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm trying to bind a data on one of my columns to data that's in my page's ViewModel (as opposed to the objects that the grid is bound to). What I have below was recommended here , to no avail. <DataGridTemplateColumn> <DataGridTemplateColumn.CellTemplate> <DataTemplate> <Button Content="{Binding ElementName=LayoutRoot, Path=DataContext.JUNK}"></Button> </DataTemplate> </DataGridTemplateColumn.CellTemplate> </DataGridTemplateColumn> In my ViewModel public string JUNK { get; set; } Which is set to "HELLO" in the ViewModel's constructor Does

DataBinding: &#039;System.Data.DataRowView&#039; does not contain a property with the name

匿名 (未验证) 提交于 2019-12-03 08:35:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am getting this weird error... the primary key in my database is 'DocumentID' so I know that is not the issue. I am trying to get the select,edit & delete gridview buttons to work but I need the datakeynames to be set correctly for them to be available to use. any ideas? <asp:GridView ID="GridView1" runat="server" DataSourceID="sdsDocuments" EnableModelValidation="True" SelectedIndex="0" OnSelectedIndexChanged="GridView1_SelectedIndexChanged" DataKeyNames="DocumentID, DocumentTitle, DocumentBody"> <Columns> <asp:BoundField DataField=

Android DataBinding &amp; MVVM - Using same layout files for different conditions using same view models

匿名 (未验证) 提交于 2019-12-03 02:47:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I've been developing an app with data binding & MVVM. I'm trying to use an alternative layout for my app on landscape mode. I have: layout/fragment_content.xml layout-land/fragment_content.xml Both layouts have same views with different look, and get feeds from same view models, like this: <layout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto"> <data class="MyBinding"> <variable name="viewModel" type="com.myapp.package.viewModel.VMFirst"/> <variable name="controlModel" type="com

Error:Data Binding does not support Jack builds yet

匿名 (未验证) 提交于 2019-12-03 02:24:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: 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 George are project member of DataBinding. we are

Kotlin-android: unresolved reference databinding

匿名 (未验证) 提交于 2019-12-03 01:58:03
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I have following fragment class written in Java using new databinding library import com . example . app . databinding . FragmentDataBdinding ; public class DataFragment extends Fragment { @Nullable private FragmentDataBinding mBinding ; @Nullable @Override public View onCreateView ( LayoutInflater inflater , ViewGroup container , Bundle savedInstanceState ) { mBinding = DataBindingUtil . inflate ( inflater , R . layout . fragment_data , container , false ); return mBinding . getRoot (); } } It compiles and runs fine. I tried to

android databinding unit test error Failed to parse data binding compiler options. Params:

匿名 (未验证) 提交于 2019-12-03 01:49:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: When I try to setup unit test for my kotlin android project, I met the following error. Any one has met this kind of issue before? This has been marked as a bug on official bug tracker FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':app:compileDebugUnitTestJavaWithJavac'. > java.lang.RuntimeException: Failed to parse data binding compiler options. Params: kapt.annotations : /Users/trevor/Dev/Android/workspace/gitlab-example/app/build/tmp/kapt/debugUnitTest/wrappers/annotations.debugUnitTest.txt kapt