无法为Android数据绑定创建自定义设置器-“找不到访问器”错误

无法为Android数据绑定创建自定义设置器-“找不到访问器”错误,第1张

概述我正在尝试按以下说明创建自定义设置器:https://developer.android.comools/data-binding/guide.html#custom_setters我的看法是:    <data><variablename="viewModel"type="com.example.feed.DummyViewModel"/></data><

我正在尝试按以下说明创建自定义设置器:
https://developer.android.com/tools/data-binding/guide.html#custom_setters

我的看法是:
    

<data>        <variable name="viewmodel"        type="com.example.Feed.Dummyviewmodel" /></data>    <linearLayout        androID:layout_wIDth="match_parent"        androID:layout_height="wrap_content"        androID:orIEntation="vertical">        <ImageVIEw            androID:layout_wIDth="match_parent"            androID:layout_height="wrap_content"            app:imageUrl="@{viewmodel.imageUrl}" />    </linearLayout></layout>

绑定是:

package com.example.Feed;import androID.databinding.BaSEObservable;import androID.databinding.BindingAdapter;import androID.Widget.ImageVIEw;public class Dummyviewmodel extends BaSEObservable {    @BindingAdapter("bind:imageUrl")    public static voID loadImage(ImageVIEw vIEw, String url) {// nothing yet    }}

文楼我得到错误:

Error:Execution Failed for task ':app:compileDeBUGJavaWithJavac'.> java.lang.RuntimeException: Found data binding errors. ****/ data binding error ****msg:Could not find accessor com.example.Feed.Dummyviewmodel.imageUrl file:/Users/tse/t/app/src/main/res/layout/fragment_main.xml loc:20:28 - 20:45 ****\ data binding error ****

我的loadImage函数有什么问题?如何制作正确的绑定适配器?

解决方法:

找不到访问器com.example.Feed.Dummyviewmodel.imageUrl

Dummyviewmodel don’t have get method: ge@R_404_5411@Url()

您也可以定义public:

public String imageUrl
总结

以上是内存溢出为你收集整理的无法为Android数据绑定创建自定义设置器-“找不到访问器”错误全部内容,希望文章能够帮你解决无法为Android数据绑定创建自定义设置器-“找不到访问器”错误所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1089833.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-27
下一篇 2022-05-27

发表评论

登录后才能评论

评论列表(0条)

保存