App组件化开发

栏目: IOS · Android · 发布时间: 6年前

内容简介:组件化开发大体就是这样的架构,最关键的是1.将2.将

组件化开发大体就是这样的架构,最关键的是 basebase_custom 组件内容的区别化。

App组件化开发

组件化开发步骤

第一步:创建组件

第二步:编码

第三步:调试配置

第四步:调试测试

1.将 isRunSingle 设置为 true ,就可以 单独调试 了,像 app 工程那样。

2.将 isRunSingle 设置为 false ,然后集成到 app 中就可以 集成测试 了。

集成测试这里有个问题,如何跳转到组件中的 Activity呢?需要用到 Alibaba 开源的 ARouter

推荐阅读 Android 组件化最佳实践 中的 四、组件间界面跳转

简单步骤:

base组件中配置 build.gradle

android {
    defaultConfig {
        ...
        javaCompileOptions {
            annotationProcessorOptions {
                arguments = [ moduleName : project.getName() ]
            }
        }
    }
}

dependencies {
    api 'com.alibaba:arouter-api:1.3.1'
    // arouter-compiler 的注解依赖需要所有使用 ARouter 的 module 都添加依赖
    annotationProcessor 'com.alibaba:arouter-compiler:1.1.4'
}
复制代码

组件中配置

android {
    defaultConfig {
        ...
        javaCompileOptions {
            annotationProcessorOptions {
                arguments = [ moduleName : project.getName() ]
            }
        }
    }
}

dependencies {
    ...
    annotationProcessor 'com.alibaba:arouter-compiler:1.1.4'
}
复制代码

在app主程序 Application 中初始化

ARouter.init(this);
复制代码

组件中被启动Activity 配置 path

@Route(path = "shop/shopCar")
public class TestActivity extends BaseActivity {}
复制代码

主程序启动 组件中 Activity


以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

XForms Essentials

XForms Essentials

Micah Dubinko / O'Reilly Media, Inc. / 2003-08-27 / USD 29.95

The use of forms on the Web is so commonplace that most user interactions involve some type of form. XForms - a combination of XML and forms - offers a powerful alternative to HTML-based forms. By pro......一起来看看 《XForms Essentials》 这本书的介绍吧!

CSS 压缩/解压工具
CSS 压缩/解压工具

在线压缩/解压 CSS 代码

JSON 在线解析
JSON 在线解析

在线 JSON 格式化工具

Base64 编码/解码
Base64 编码/解码

Base64 编码/解码