【问题标题】:Enabled attribute not working in button启用的属性在按钮中不起作用
【发布时间】:2015-10-10 20:44:02
【问题描述】:

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

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

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

【问题讨论】:

    标签: android robobinding


    【解决方案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

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

    【讨论】:

    • 那么,visibility 属性不是 simpleOneWayProperty?因为它的工作方式与我在示例中显示的方式相同。
    猜你喜欢
    • 2014-03-05
    • 2014-11-09
    • 1970-01-01
    • 2019-09-05
    • 2011-04-06
    • 1970-01-01
    • 2019-07-23
    • 1970-01-01
    • 2013-12-07
    相关资源
    最近更新 更多