android-databinding

When to use Android’s LiveData and Observable field?

我的未来我决定 提交于 2020-05-10 15:17:12
问题 I’m implementing a MVVM and data-binding and I’m trying to understand when should I use Observable field over LiveData? I already run through different documentations and discovered that LiveData is lifecycle aware, but in sample codes in Github these two are being used in ViewModel at the same time. So, I’m confused if LiveData is better than Observable field, why not just use LiveData at all? 回答1: Both have their use-cases, for instance: If you want a life-cycle tolerant container for your

androidx.navigation:navigation-fragment:2.2.0, get “You must call removeView() on the child's parent first.” on navController.popBackStack()

泪湿孤枕 提交于 2020-04-30 08:51:47
问题 I like use data binding and navigation graph. But after update androidx dependencies from androidx.navigation:navigation-fragment:2.0.0 on 2.2.0 application is crashed after press button "Back". Crash always after return from other fragment to previous fragment containing FragmentPagerAdapter. in build.gradle dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation 'androidx.constraintlayout:constraintlayout:1.1.3' // This is work // implementation 'androidx

androidx.navigation:navigation-fragment:2.2.0, get “You must call removeView() on the child's parent first.” on navController.popBackStack()

半世苍凉 提交于 2020-04-30 08:48:13
问题 I like use data binding and navigation graph. But after update androidx dependencies from androidx.navigation:navigation-fragment:2.0.0 on 2.2.0 application is crashed after press button "Back". Crash always after return from other fragment to previous fragment containing FragmentPagerAdapter. in build.gradle dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation 'androidx.constraintlayout:constraintlayout:1.1.3' // This is work // implementation 'androidx

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

Html.fromHtml in DataBinding - Android

天涯浪子 提交于 2020-04-10 17:45:22
问题 I am using from dataBinding in my project,when I have bellow xml it good work : <TextView android:id="@+id/txtDateCreate" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@{String.format(@string/DateCreate,others.created)}" /> But when I change to bellow get me crash: <TextView android:id="@+id/txtDateCreate" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@{Html.fromHtml(String.format(@string/DateCreate,others

Retain EditText with Screen Rotation using Databinding Library

徘徊边缘 提交于 2020-04-05 06:51:07
问题 I have two classes AdminPinActivity.kt and AdminPinActivityPresenter.kt AdminPinActivity.kt: class AdminPinActivity : InjectableAppCompatActivity() { @Inject lateinit var adminPinActivityPresenter: AdminPinActivityPresenter private var input_Pin: String = "" private var input_Confirm_Pin: String = "" companion object { fun createAdminPinActivityIntent(context: Context, profileId: Int, colorRgb: Int): Intent { val intent = Intent(context, AdminPinActivity::class.java) intent.addFlags(Intent

Get values other views when onClick. DataBinding

我们两清 提交于 2020-03-23 11:58:12
问题 I have xml with android data binding: <?xml version="1.0" encoding="utf-8"?> <layout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto"> <data> <variable name="presenter" type="com.myapp.presentation.presenter.CreateUserPresenter"/> </data> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical"> <android.support.design.widget.TextInputLayout android:id="@+id

How to use kotlin.Int in databinding?

折月煮酒 提交于 2020-03-22 10:47:05
问题 I wrote a layout xml like below. But the Kotlin compiler says Cannot resolve symbol 'Int' main_activity.xml <?xml version="1.0" encoding="utf-8"?> <layout ...> <data> <import type="androidx.databinding.ObservableArrayMap" /> <variable name="myList" type="ObservableArrayMap<Int,String>" /> </data> <!-- ...... --> </layout> Is it possible to use kotlin builtins in android databinding xml? 回答1: Use java Integer instead of kotlin Int . You can not use characters <,> etc in XML. So use HTML

Exception when using data binding in fragment: “The specified child already has a parent. You must call removeView() on the child's parent first”

半腔热情 提交于 2020-03-16 05:39:51
问题 Android Studio 3.1, java 1.8 I try to use data binding: Here settings.xml layout: <layout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto"> <data> <variable name="handler" type="com.myproject.SettingsFragment" /> </data> <android.support.constraint.ConstraintLayout android:layout_width="match_parent" android:layout_height="match_parent"> <ScrollView android:layout_width="match_parent" android:layout_height="match_parent">

Exception when using data binding in fragment: “The specified child already has a parent. You must call removeView() on the child's parent first”

百般思念 提交于 2020-03-16 05:38:25
问题 Android Studio 3.1, java 1.8 I try to use data binding: Here settings.xml layout: <layout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto"> <data> <variable name="handler" type="com.myproject.SettingsFragment" /> </data> <android.support.constraint.ConstraintLayout android:layout_width="match_parent" android:layout_height="match_parent"> <ScrollView android:layout_width="match_parent" android:layout_height="match_parent">