栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

as 通信

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

as 通信

activity跳转到另一个activity

https://blog.csdn.net/jiayu0855/article/details/78759471

Intent intent=new Intent(MainActivity.this, SecondActivity.class); startActivity(intent);```
activity之间传递消息

https://blog.csdn.net/blueair_ren/article/details/52818778
1,intent

@1通过Intent向下一个活动发送数据。
String data = "nihao";                                                                      Intent intent = new Intent(activity1.this,activity2.class);
intent.putExtra("send_data",data);
startActivity(intent);
@2通过intent接收来自上一个活动的数据。
Intent intent = getIntent();
String data = intent.getStringExtra("send_data");

2.bundle
第一个activity

       Intent intent=new Intent(MainActivity.this, SecondActivity.class);
                Bundle bundle = new Bundle();
                bundle.putString("aa","ddkkddk");
                intent.putExtras(bundle);
                startActivity(intent);

第二个activity

    final Intent intent = getIntent();
        Bundle bundle = intent.getExtras();
        Log.e("leo", "onCreate: " + bundle.getString("aa"));

3.activity 与 fragment通信

    Bundle bundle = new Bundle();
                bundle.putString("message","我喜欢享学课堂");
                BlankFragment1 bf = new BlankFragment1();
                bf.setArguments(bundle);
                replacefragment(bf);
      Bundle bundle=this.getArguments();
        Log.e("leo", "onCreate: "+ bundle.getString("message"));
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/644744.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号