全部博文(120)
分类: LINUX
2010-09-26 15:58:18
1.Using Bundle to
transfer the data between activities
public class myClass extends Activity
{
Intent myIntent = new Intent();
myIntent.setClass(myclase.this,other.class);
Bundle myBundle = newBundle ();
myBundle.putDouble("height",height);
myBundle.putString("sex",sex);
myIntent.putExtras(myBundle);
startActivity(myIntent);
myClass.this.finish;
}
2.get the data
from the passing activity
public class otherClass extends Activity
{
Bundle myBundle
= this.getIntent.getExtras();
String sex = myBundle.getString("sex");
Double height = myBundle.getDouble("height");
TextView tv = (TextView)findViewByid(R.id.text1);
if (sex.equals("M"))
tv.setText("Male");
else
tv.setText("Female");
}
chinaunix网友2010-09-27 10:44:14
很好的, 收藏了 推荐一个博客,提供很多免费软件编程电子书下载: http://free-ebooks.appspot.com