当前位置:网站首页>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)
边栏推荐
猜你喜欢
SCM polling program framework based on linked list management
好博医疗冲刺科创板:年营收2.6亿 万永钢和沈智群为实控人
JVM memory layout detailed, illustrated, well written!
【Matlab】conv、filter、conv2、filter2和imfilter卷积函数总结
Understanding and difference between viewbinding and databinding
CVPR 2022 | 大幅减少零样本学习所需的人工标注,提出富含视觉信息的类别语义嵌入(源代码下载)...
吃透Chisel语言.06.Chisel基础(三)——寄存器和计数器
Redis - how to install redis and configuration (how to quickly install redis on ubuntu18.04 and centos7.6 Linux systems)
Doctoral application | West Lake University Learning and reasoning system laboratory recruits postdoctoral / doctoral / research internship, etc
[R language data science]: cross validation and looking back
随机推荐
Secretary of Homeland Security of the United States: domestic violent extremism is one of the biggest terrorist threats facing the United States at present
Detailed explanation of Fisher information quantity detection countermeasure sample code
IDEA快捷键大全
吃透Chisel语言.12.Chisel项目构建、运行和测试(四)——Chisel测试之ChiselTest
Understanding and difference between viewbinding and databinding
MySQL5免安装修改
China Post technology rushes to the scientific innovation board: the annual revenue is 2.058 billion, and the postal group is the major shareholder
2022g3 boiler water treatment examination question simulation examination question bank and simulation examination
Whether the loyalty agreement has legal effect
Gorm 读写分离(转)
PHP log debugging
MySQL 5 installation and modification free
gorm 之数据插入(转)
Unity shader learning (3) try to draw a circle
Migration from go vendor project to mod project
[antd] how to set antd in form There is input in item Get input when gourp Value of each input of gourp
2022 Shandong Province safety officer C certificate examination question bank and online simulation examination
基于PaddleX的智能零售柜商品识别
Idea shortcut keys
硬件基础知识-二极管基础