启用的属性无法在按钮中工作

时间:2015-10-10 20:44:02

标签: android robobinding

我正在使用此链接(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)
......

如果我改为&#34;可见度&#34;属性它工作正常。

&#34;启用&#34;按钮支持哪个属性?

1 个答案:

答案 0 :(得分: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/main/java/org/robobinding/widget/ratingbar/RatingBarBinding.java