位置:首页> 开发 > 数据存储 > 浏览文章

Android中使用Bundle进行数据传递和存储[页16]

2023-08-23
javaBundle bundle = getIntent().getExtras();
boolean isStudent = bundle.getBoolean("isStudent");
  1. 传递对象数据
javaIntent intent = new Intent(MainActivity.this, SecondActivity.class);
Bundle bundle = new Bundle();
Student student = new Student("John", 25, true);
bundle.putSerializable("student", student);
intent.putExtras(bundle);
startActivity(intent);

在目标Activity中获取数据:

首页 上一页 12 13 14 15 1617 18 下一页 尾页
下一篇:

相关阅读

热门推荐