文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>Share data between Activities

Share data between Activities

时间:2010-09-26  来源:xiaosuzi

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");

}


相关阅读 更多 +
排行榜 更多 +
辰域智控app

辰域智控app

系统工具 下载
网医联盟app

网医联盟app

运动健身 下载
汇丰汇选App

汇丰汇选App

金融理财 下载