EventBus传值及生成索引
来源:互联网 发布:淘宝商品详情页面html 编辑:程序博客网 时间:2024/06/03 15:26
在project的build.gradle下配置:
dependencies { classpath 'com.android.tools.build:gradle:3.0.1' classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8' //EventBus配置 // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files }
在App的build.gradle下配置:
android { defaultConfig { javaCompileOptions { annotationProcessorOptions { arguments = [ eventBusIndex : 'com.example.myapp.MyEventBusIndex' ] } } }}dependencies { compile 'org.greenrobot:eventbus:3.0.0' annotationProcessor 'org.greenrobot:eventbus-annotation-processor:3.0.1'}
在MyApp extends Application中注册配置:
EventBus eventBus = EventBus.builder().addIndex(new MyEventBusIndex()).build();MyEventBusIndex的文件必须在注册、订阅和发送完成的时候才会生成
(1)自定义一个类,可以是空类,比如:
- public class AnyEventType {
- public AnyEventType(){}
- }
(2)在要接收消息的页面注册:
- eventBus.register(this);
(3)发送消息
- eventBus.post(new AnyEventType event);
(4)接受消息的页面实现(共有四个函数,各功能不同,这是其中之一,可以选择性的实现,这里先实现一个):
- public void onEvent(AnyEventType event) {}
阅读全文
0 0
- EventBus传值及生成索引
- 生成索引信息及索引创建脚本
- 生成索引信息及索引创建脚本
- 生成索引信息及索引创建脚本
- 蛇形矩阵生成及索引
- EventBus简单传值
- EventBus的传值
- PowerDesigner 创建唯一索引及生成comment
- EventBus简单使用传值
- EventBus两个页面传值
- EventBus 3.0——线程、界面之间传值及不同界面接收特定消息
- EventBus简介及使用
- EventBus使用及优点
- EventBus 了解及应用
- EventBus添加索引和ButterKnife依赖
- EventBus 页面传值并启动Activity
- EventBus的两个Activity的传值
- EventBus :概述及基本概念 《一》
- 最小和(sicily算法)
- python数据结构详细解析
- 小心情
- SQL语句之ORDER BY子句
- 归并排序
- EventBus传值及生成索引
- 可持久化学习总结
- 网络获取gson数据解析(老办法)
- 【Scikit-Learn 中文文档】协方差估计 / 经验协方差 / 收敛协方差 / 稀疏逆协方差 / Robust 协方差估计
- shell学习二十六--linux下随机数获取方法
- 信息安全_待加
- cs231n关于反向传播的理解
- OpenCV学习2 模板匹配
- 使用函数的调用来依次输入三个数的大小