MVVM中的xmlns:tools和xmlns:bind之间的区别

时间:2019-01-05 11:17:35

标签: android mvvm android-mvvm

我正在学习如何使用MVVM进行开发。我创建了一个小示例,如下代码所示。 我的问题是关于xmlns的:在某些教程中,他们使用了xmlns:bind,而在其他xmlns:tools中则使用了

请让我知道其差异以及何时使用。

xml

<?xml version="1.0" encoding="utf-8"?>
<layout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:bind="http://schemas.android.com/tools">

<data>
    <!-- the class the behaves as Viewmodel and contains the @Bindable Object-->
    <variable
        name="vm1"
        type="com.example.amrbakri.mvvm_02.LoginViewModel1" />
</data>


<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <TextView
        android:id="@+id/actMain_LoginViewModel1_tv_results"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:visibility="visible"
        android:text="@{vm1.result}"
        />
</LinearLayout>
</layout>

0 个答案:

没有答案