传值方法一
Intent intent = new Intent();
Bundle bundle = new Bundle(); //该类用作携带数据
bundle.putString("name", "tom");
bundle.putString("ip","8.8.8.8");
intent.putExtras(bundle); //为Intent追加额外的数据
传值方法二
Intent intent = new Intent();
intent.putExtra("name", "tom");
intent.putExtra("money", 1098978009L);
获取值
Bundle bundle=getIntent().getExtras();
String name=bundle.getString("name");
本文介绍了在Android应用程序中使用Intent和Bundle实现不同组件间数据传递的方法。通过两种常见方式:一是利用Bundle打包数据并附加到Intent;二是直接通过Intent.putExtra()方法传递数据。
842

被折叠的 条评论
为什么被折叠?



