databindin报错之:pkgName: com.example.databinding has no permission

<?xml version="1.0" encoding="utf-8"?>

<layout xmlns:android="http://schemas.android.com/apk/res/android"

    xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"

android:layout_height="match_parent"

tools:context=".MainActivity

>



        上面这个不及时删除,就会报错:system_server                        E  pkgName: com.example.databinding has no permission

-->

    <!-- Data 标签,声明ViewModel -->

   

            name="viewModel"

            type="com.example.databinding.UserViewModel" />

        android:layout_width="match_parent"

        android:layout_height="match_parent"

        android:orientation="vertical"

        android:padding="16dp"

        tools:context=".MainActivity">

            android:layout_width="match_parent"

            android:layout_height="wrap_content"

            android:hint="请输入姓名"

            android:text="@={viewModel.userName}" /> <!-- 双向绑定 -->


            android:layout_width="match_parent"

            android:layout_height="wrap_content"

            android:hint="请输入年龄"

            android:inputType="number"

            android:text="@={viewModel.userAge}" /> <!-- 双向绑定 -->


            android:layout_width="match_parent"

            android:layout_height="wrap_content"

            android:layout_marginTop="16dp"

            android:text="实时预览:" />

            android:layout_width="match_parent"

            android:layout_height="wrap_content"

            android:text="@{`姓名: ` + viewModel.userName + `, 年龄: ` + viewModel.userAge}" />

        <!-- 直接展示绑定数据 -->


</layout>

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容