展会信息港展会大全

Android开发中使用Bundle在Activity间传递数据
来源:互联网   发布日期:2016-01-14 09:27:34   浏览:2580次  

导读:从源Activity 中传递数据 数据写入IntentIntent openWelcomeActivityIntent=new Intent();Bundle myBundelForName=new Bundle();myBundelForName putString(Key_Name,inName getText() toString());myBu ...

从源Activity 中传递数据

//数据写入Intent

Intent openWelcomeActivityIntent=new Intent();

Bundle myBundelForName=new Bundle();

myBundelForName.putString("Key_Name",inName.getText().toString());

myBundelForName.putString("Key_Age",inAge.getText().toString());

openWelcomeActivityIntent.putExtras(myBundelForName);

openWelcomeActivityIntent.setClass(AndroidBundel.this, Welcome.class);

startActivity(openWelcomeActivityIntent);

目标Activity 中获取数据

//从Intent 中获取数据

Bundle myBundelForGetName=this.getIntent().getExtras();

String name=myBundelForGetName.getString("Key_Name");

myTextView_showName.setText("欢迎您进入:"+name);

赞助本站

人工智能实验室
AiLab云推荐
推荐内容
展开

热门栏目HotCates

Copyright © 2010-2024 AiLab Team. 人工智能实验室 版权所有    关于我们 | 联系我们 | 广告服务 | 公司动态 | 免责声明 | 隐私条款 | 工作机会 | 展会港