0

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

我正在尝试在这样的按钮中使用“启用”属性:

<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)
......

如果我更改为“可见性”属性,它可以正常工作。

按钮是否支持“启用”属性?

4

1 回答 1

1

您应该使用来自 RoboBinding 主页的新“API 和绑定属性 JavaDocs”链接。

所有 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/主/java/org/robobinding/widget/ratingbar/RatingBarBinding.java

于 2015-10-24T07:00:59.990 回答