Eclipse ADT 项目中的 Android 数据绑定(无 gradle)

Posted

技术标签:

【中文标题】Eclipse ADT 项目中的 Android 数据绑定(无 gradle)【英文标题】:Android Data binding in Eclipse ADT project (without gradle) 【发布时间】:2018-02-07 10:37:10 【问题描述】:

我正在尝试在没有 gradle 的 Eclipse(Juno) ADT 项目中实现 android 数据绑定库。当我尝试在布局下添加数据标签时,出现以下错误 变量

中的“属性缺少命名空间前缀”
    <layout xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:tools="http://schemas.android.com/tools">
   <data>
       <variable name="user" type="com.example.User"/>
   </data>
<LinearLayout 
    android:background="#ffffff"
    android:layout_
    android:layout_
    android:padding="@dimen/activity_horizontal_margin"
    tools:context="com.example.exam"
    android:orientation="vertical"
    android:focusable="true" 
    android:focusableInTouchMode="true"
    >
   <TextView 
        android:id="@+id/label_name"
        android:layout_marginTop="20dp"
        android:layout_
        android:layout_
        android:text="CLASS NAME"
        android:textColor="@color/colorBlue"
        android:textSize="13sp"
        />
    </LinearLayout>
</layout>

我认为问题是由于我没有使用 gradle 来构建我的项目,因此我在 ADT 非 gradle 项目中没有以下等价物

android 
    ....
    dataBinding 
        enabled = true
    

谁能帮助我如何将数据绑定用于非 gradle ADT eclipse 项目?

【问题讨论】:

【参考方案1】:

gradle 构建确实会生成编译时类来为您进行绑定,因此如果您不使用 gradle 并且 Google 不提供其他解决方案,您将需要转向其他解决方案。

【讨论】:

我切换到 android studio,因为我找不到任何其他选项

以上是关于Eclipse ADT 项目中的 Android 数据绑定(无 gradle)的主要内容,如果未能解决你的问题,请参考以下文章

ADT (Eclipse) vs. Android Studio:APK文件大小相差多少是正常的?

用于 android 开发的 adt-bundle 中的 Eclipse 通过自动完成冻结

为Eclipse安装ADT(Android Development Tools)

为啥 Eclipse 的 Adt 插件不起作用?

如何在 Eclipse 中使用 Gradle 和 ADT?

用Eclipse创建android项目后src报错,怎么解决?