当前位置:网站首页>ARouter的使用
ARouter的使用
2022-07-04 12:50:00 【菜鸟xiaowang】
一个用于帮助 Android App 进行组件化改造的框架 支持模块间的路由、通信、解耦
1.基本使用:
defaultConfig { applicationId "com.example.greendao" minSdk 29 targetSdk 31 versionCode 1 versionName "1.0" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 配置 javaCompileOptions { annotationProcessorOptions { arguments = [AROUTER_MODULE_NAME: project.getName()] } } }
dependencies { implementation 'com.alibaba:arouter-api:1.5.2' annotationProcessor 'com.alibaba:arouter-compiler:1.5.2'}
2.初始化
在application里进行
ARouter.init(this);
3.使用
在要跳转的activity上配置Route注解
@Route(path = "/test/MainActivity2")
跳转代码
ARouter.getInstance().build("/test/MainActivity2") 要跳转的界面 .withString("name","eeeeee") .withString("age","30").navigation();携带的参数
4.数据解析 数据自动注入
@Route(path = "/test/MainActivity2")
public class MainActivity2 extends AppCompatActivity {
@Autowired(name = "name")
String name;
@Autowired(name = "age")
String age;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main2);
ARouter.getInstance().inject(this);
Log.e("MainActivity2",name+age);
}
官方使用说明:gARouter: ARouter 是阿里开源的一个 Android 路由中间件,用于对页面、服务提供路由功能 (gitee.com)
边栏推荐
- Understand chisel language thoroughly 05. Chisel Foundation (II) -- combinational circuits and operators
- Product identification of intelligent retail cabinet based on paddlex
- 吃透Chisel语言.05.Chisel基础(二)——组合电路与运算符
- FS4059C是5V输入升压充电12.6V1.2A给三节锂电池充电芯片 输入小电流不会拉死,温度60°建议1000-1100MA
- Summary of recent days (non-technical article)
- Secretary of Homeland Security of the United States: domestic violent extremism is one of the biggest terrorist threats facing the United States at present
- What is the real meaning and purpose of doing things, and what do you really want
- SCM polling program framework based on linked list management
- Common content type correspondence table
- 華昊中天沖刺科創板:年虧2.8億擬募資15億 貝達藥業是股東
猜你喜欢
Understand chisel language thoroughly 06. Chisel Foundation (III) -- registers and counters
英视睿达冲刺科创板:年营收4.5亿 拟募资9.79亿
Redis - how to install redis and configuration (how to quickly install redis on ubuntu18.04 and centos7.6 Linux systems)
Hardware Basics - diode Basics
China Post technology rushes to the scientific innovation board: the annual revenue is 2.058 billion, and the postal group is the major shareholder
吃透Chisel语言.10.Chisel项目构建、运行和测试(二)——Chisel中生成Verilog代码&Chisel开发流程
Unittest框架中引入TestFixture
Summary of recent days (non-technical article)
sharding key type not supported
Interviewer: what is the internal implementation of hash data type in redis?
随机推荐
Migration from go vendor project to mod project
CVPR 2022 | greatly reduce the manual annotation required for zero sample learning, and propose category semantic embedding rich in visual information (source code download)
MongoDB常用28条查询语句(转)
Understand chisel language thoroughly 10. Chisel project construction, operation and testing (II) -- Verilog code generation in chisel & chisel development process
Ruichengxin micro sprint technology innovation board: annual revenue of 367million, proposed to raise 1.3 billion, Datang Telecom is a shareholder
golang fmt.printf()(转)
Gorm read / write separation (rotation)
[matlab] summary of conv, filter, conv2, Filter2 and imfilter convolution functions
基于YOLOv1的口罩佩戴检测
忠诚协议是否具有法律效力
Understand chisel language thoroughly 04. Chisel Foundation (I) - signal type and constant
Can mortgage with housing exclude compulsory execution
2022 Shandong Province safety officer C certificate examination question bank and online simulation examination
Install and use MAC redis, connect to remote server redis
392. 判断子序列
DGraph: 大规模动态图数据集
WS2818M是CPC8封装,是三通道LED驱动控制专用电路外置IC全彩双信号5V32灯可编程led灯带户外工程
find命令报错: paths must precede expression(转)
【R语言数据科学】:交叉验证再回首
2022 practice questions and mock exams for the main principals of hazardous chemical business units