有没有办法与Lombok访问器进行Android绑定?

时间:2016-05-21 01:13:20

标签: android-layout lombok android-binding-adapter

我开始玩Android绑定了。标准(单向)绑定对我和我一起出去的人来说足够好。

但是,我发现在没有Could not find accessor错误的情况下我无法使用Lombok访问器。你有没有找到解决这个问题的方法,羞于手动编写像某种龙目岛无知的洞穴猎人那样的吸气剂和装置者?

@Bindable
@Getter @Setter
private String stringField;

//Must uncomment hand-coded accessors to compile!
//public String getStringField() { return stringField;}
//public void setStringField(String s) { stringField = s;}

对于后人来说,我的原始示例代码使用的是布尔值,这会使问题稍微浮现一下:

    @Bindable 
    @Getter @Setter private boolean showpassword = false;

/*  This only compiles if the handcoded accessors are uncommented.

    public boolean getShowpassword() {
        return showpassword;
    }
    public void setShowpassword(boolean b) {
        showpassword = b;
    }
*/

1 个答案:

答案 0 :(得分:1)

对于boolean,默认情况下生成的“getter”为isShowpassword,遵循beanspec。生成的“setter”为setShowPassword。错误消息表明它是无法找到的“getter”。

您可以使用配置键更改此行为。根据{{​​3}},如果您在documentation中包含以下内容,则您的程序应该在没有手写getter和setter的情况下工作:

lombok.getter.noIsPrefix = true