什么是"包"在Android应用程序 [英] What is a "bundle" in an Android application

查看:200
本文介绍了什么是"包"在Android应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是 在Android应用程序?当使用它?

解决方案

包一般用于通过各种活动机器人之间的数据

。这取决于你,你想传递什么类型的值,但是包可以容纳所有类型的值,并通过新的活动。

您可以使用它像:

 意向意图=新...
意图(getApplicationContext(),SecondActivity.class);
intent.putExtra(的myKey,AnyValue);
startActivity(意向);
 

现在你可以得到传递的值:

 捆绑额外= intent.getExtras();
串TMP = extras.getString(的myKey);
 

您可以找到更多信息的:

  • <一个href="http://miragemiko.word$p$pss.com/2010/03/20/android-using-bundle-for-sharing-variables/">android-using-bundle-for-sharing-variables以及

  • <一个href="http://www.remwebdevelopment.com/dev/a33/Passing-Bundles-Around-Activities.html">Passing-Bundles-Around-Activities

What is a bundle in an Android application? When to use it?

解决方案

Bundle is generally used for passing data between various activities of android. It depends on you what type of values you want to pass, but bundle can hold all types of values, and pass to the new activity.

You can use it like:

Intent intent = new...
Intent(getApplicationContext(), SecondActivity.class);
intent.putExtra("myKey", AnyValue);  
startActivity(intent);

Now you can get the passed values by:

Bundle extras = intent.getExtras(); 
String tmp = extras.getString("myKey");

You can find more info on:

这篇关于什么是&QUOT;包&QUOT;在Android应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆