RoboBinding 正在参加 2021 年度 OSC 中国开源项目评选,请投票支持!
RoboBinding 在 2021 年度 OSC 中国开源项目评选 中已获得 {{ projectVoteCount }} 票,请投票支持!
2021 年度 OSC 中国开源项目评选 正在火热进行中,快来投票支持你喜欢的开源项目!
2021 年度 OSC 中国开源项目评选 >>> 中场回顾
RoboBinding 获得 2021 年度 OSC 中国开源项目评选「最佳人气项目」 !
授权协议 Apache
开发语言 Java 查看源码 »
操作系统 Android
软件类型 开源软件
开源组织
地区 国产
投 递 者 cheng112
适用人群 未知
收录时间 2014-09-14

软件简介

RoboBinding是一个实现了数据绑定 Presentation Model(MVVM) 模式的Android开源框架。从简单的角度看,他移除了如addXXListener(),findViewById()这些不必要的代码,连如BufferKnife那样的InjectView都不需要,因为你的代码一般不需要依赖于这些界面组件信息。下面以一个最简单的AndroidMVVM为例。

Layout:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:bind="http://robobinding.org/android">
    <TextView
        bind:text="{hello}" />
        ...
    <Button
        android:text="Say Hello"
        bind:onClick="sayHello"/>
</LinearLayout>

Presentation Model:

public class PresentationModel extends AbstractPresentationModel {
    private String name;
    public String getHello() {
        return name + ": hello Android MVVM(Presentation Model)!";
    }
    ...
    public void sayHello() {
        firePropertyChange("hello");
    }
}

Activity将layout与对应的presentation model绑定在一起。

public class MainActivity extends Activity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        ...
        PresentationModel presentationModel = new PresentationModel();
        View rootView = Binders.inflateAndBindWithoutPreInitializingViews(this, R.layout.activity_main, presentationModel);
        setContentView(rootView);
    }
}

这样layout的{hello}与PresentationModel.hello绑定,layout的sayHello与PresenationModel.sayHello方法绑定。我们不需要在Layout中定义TextView, Button的Id因为我们不关心,且没有必要。当我们进一步观察时,我们发现PresentationModel是一个Pure POJO。这也是为什么软件界的泰斗Martin Fowler在2004年,提出了Presenation Model(MVVM) 模式。它是我们所熟悉的MVC的升级,进一步的把界面状态与逻辑解藕到Presentation Model中。我们可以通过以下几个示例项目学习RoboBinding使用,他们都可以直接导入Android Studio无需额外配置:

1.AndroidMVVM,最小的RoboBinding使用例子。

2.Album Sample,是Martin Fowler的Presentation Model模式原始例子基于RoboBinding的Android翻译版本。

3.Gallery,是用于展示RoboBinding的各种特性的使用包含Fragment, Menu, ViewPager等。

项目的中文文档地址是:http://robobinding.github.io/RoboBinding/index.zh.html

展开阅读全文

代码

的 Gitee 指数为
超过 的项目

评论

点击加入讨论🔥(4)
发表了资讯
2015/08/02 00:00

RoboBinding 0.8.10 发布 - Android数据绑定框架

RoboBinding 0.8.10 发布了,在这个新版本中,你可以为80%以上的Android Views或自定义Views声明简单单向绑定如下。RoboBinding为你产生代码。没有性能影响,纯静态。 @ViewBinding(simpleOneWayProperties={"typeface"}) class MyTextViewBinding extends CustomViewBinding<TextView> {   ... } 这样,你就可以开始使用typeface这个属性来做绑定了。详细请从这里开始了解。...

11
19
发表了资讯
2014/09/27 00:00

RoboBinding 0.8.8 发布,Android数据绑定框架

RoboBinding目前是最受欢迎的Android native MVVM框架。其他的有Android Binding,Bindroid等。 RoboBinding是一个实现了数据绑定 Presentation Model(MVVM) 模式的Android开源框架。请看框架介绍与最简单的AndroidMVVM了解学习。MVVM模式是MVC模式的重要更新,使得项目结构更加的优美,易于维护以及方便于测试。这也是为什么几个主流的语言都有相应的MVVM框架实现如Microsfot WPF, Silverlight,JavaFX以及Flex。 项目的地址也...

0
38
发表了资讯
2014/09/21 00:00

RoboBinding 0.8.6 发布,Android数据绑定框架

首先恭喜RoboBinding成为最流行的Android native MVVM框架。 RoboBinding是一个实现了数据绑定 Presentation Model(MVVM) 模式的Android开源框架。请看框架介绍了解学习。MVVM模式是MVC模式的重要更新,使得项目结构更加的优美,易于维护以及方便于测试。这也是为什么几个主流的语言都有相应的MVVM框架实现如Microsfot WPF, Silverlight,JavaFX以及Flex。 项目的地址也入门介绍: 框架首页 - https://github.com/RoboBinding/R...

8
21
没有更多内容
加载失败,请刷新页面
点击加载更多
加载中
下一页
发表了博客
{{o.pubDate | formatDate}}

{{formatAllHtml(o.title)}}

{{parseInt(o.replyCount) | bigNumberTransform}}
{{parseInt(o.viewCount) | bigNumberTransform}}
没有更多内容
暂无内容
发表了问答
{{o.pubDate | formatDate}}

{{formatAllHtml(o.title)}}

{{parseInt(o.replyCount) | bigNumberTransform}}
{{parseInt(o.viewCount) | bigNumberTransform}}
没有更多内容
暂无内容
暂无内容
4 评论
240 收藏
分享
OSCHINA
登录后可查看更多优质内容
返回顶部
顶部