Android之activity跳转并且回调
16lz
2021-01-25
假设A页面要跳到B页面,A页面需要获取B页面传回来的参数来确定显示哪个列表。主要代码如下:
在A页面中:
Intent intent = new Intent();
intent.setClass(A.this, B.class);
startActivityForResult(intent,REQUESTCODE);//REQUESTCODE定义一个整型做为请求对象标识
跳转到B,在B页面中:
B.setResult(parama, getIntent());//定义返回的参数parama
B.finish();
返回到A,在A页面中:
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
//resultCode就是在B页面中返回时传的parama,可以根据需求做相应的处理
}
更多相关文章
- 安全新手入坑——HTML标签
- Nginx系列教程(四)| 一文带你读懂Nginx的动静分离
- android自定义注解的运用
- context.obtainStyledAttributes 研究
- android标题栏中添加返回按钮
- Android(安卓)ListView的OnItemClickListener()参数详解
- Android(安卓)popupWindow 用法
- android 实现男女按钮选择
- Android(安卓)模糊搜索rawquery bind or column index out of ra