启用的属性在按钮中不起作用

Enabled attribute not working in button

我正在使用这个 link (http://robobinding.github.io/RoboBinding/old_binding_attributes.html) 来检查哪些属性可用。

我正尝试在这样的按钮中使用 "enable" 属性:

<Button
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
     android:text="start"
     android:id="@+id/start_button"
     bind:enable="{canStart}" />

但是每当我 运行 应用程序时,我都会收到以下错误:

enabled: Unrecognized attribute 'enabled'
    -------------------------The first error stack trace-----------------------
    enabled: Unrecognized attribute 'enabled'
            at org.robobinding.PendingAttributesForViewImpl.getResolutionErrors(PendingAttributesForViewImpl.java:43)
            at org.robobinding.binder.BindingAttributeResolver.resolve(BindingAttributeResolver.java:39)
            at org.robobinding.binder.BindingViewInflater.resolveAndAddViewBindingAttributes(BindingViewInflater.java:90)
            at org.robobinding.binder.BindingViewInflater.onViewCreated(BindingViewInflater.java:85)
            at org.robobinding.ViewFactory.notifyViewCreatedIfNotNull(ViewFactory.java:65)
            at org.robobinding.ViewFactory.onCreateView(ViewFactory.java:58)
            at android.view.LayoutInflater$FactoryMerger.onCreateView(LayoutInflater.java:177)
            at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:725)
......

如果我更改为 "visibility" 属性,它工作正常。

按钮是否支持 "enabled" 属性?

您应该使用 RoboBinding 主页上的新 'API and Binding Attributes JavaDocs' link。

所有 simpleOneWayProperties 都已从 RoboBinding 框架中删除,因为它们可以在需要时声明。下面的示例可以从 RoboBinding Gallery 项目中找到。

@ViewBinding(simpleOneWayProperties = {"enabled"})
  public class ViewBindingForView extends CustomViewBinding< View> {
}

注册它:

reusableBinderFactory = new BinderFactoryBuilder()
  .add(new ViewBindingForView().extend(View.class))
  .build();

View Visibility 是一个 OneWayMultiTypeProperty,因为它支持 Boolean 和 Integer。源代码在这里 - https://github.com/RoboBinding/RoboBinding/blob/develop/framework/src/main/java/org/robobinding/widget/view/ViewBindingForView.java

对于小部件支持的属性绑定,除了查看 javadoc 之外,您还可以在 ViewBinding 实现中找到已实现的绑定信息,例如 RatingBar - https://github.com/RoboBinding/RoboBinding/blob/develop/framework/src/main/java/org/robobinding/widget/ratingbar/RatingBarBinding.java