首页
学习
活动
专区
圈层
工具
发布

【JetPack】视图绑定 ( ViewBinding ) 各种应用 ( 视图绑定两种方式 | Activity 布局 | 对话框布局 | 自定义组件布局 | RecyclerView 列表布局 )

XxxBinding.inflate( LayoutInflater ) 与界面绑定 : 这种方式加载的布局与界面关联性不大 , 需要调用额外的函数 , 将视图绑定类与界面进行绑定 , Activity...获取视图绑定类 binding = ActivityMainBinding.inflate(getLayoutInflater()); // 2 ....; ① 获取视图绑定类 : 使用 DialogBinding binding = DialogBinding.inflate(getLayoutInflater()) 只是单纯的加载布局 ; ② 关联界面...获取视图绑定类 DialogBinding binding = DialogBinding.inflate(getLayoutInflater()); // 2 ....获取布局加载器 LayoutInflater inflater = LayoutInflater.from(this.getContext()); // 2 .

2.4K30
  • 您找到你想要的搜索结果了吗?
    是的
    没有找到

    移动开发作业一

    创建一个适配器类,用于将数据与 RecyclerView 绑定。适配器类应根据每个选项卡的数据需求自定义,包括数据源、视图绑定和点击事件处理。...LayoutInflater.from(parent.getContext()).inflate(R.layout.item_message, parent, false),从布局文件item_message.xml...图片 View对象view用于加载片段的布局,通过inflater.inflate方法将布局文件R.layout.wetalks填充到片段中。这个布局包含一个RecyclerView控件。...创建一个MessageAdapter对象messageAdapter,并将消息数据messages传递给它,这样可以将消息数据与RecyclerView绑定。...由于Gradle的版本问题,不能使用switch-case语句,注意隐藏其他片段,以确保只显示一个特定的片段。 GitHub仓库地址 https://github.com/k13in/WeTalks

    76830
    领券