在两个Activity之间传递对象

1806阅读 0评论2011-12-26 cnljh
分类:嵌入式

  1. 以下代码由网友提供,未经测试。

  2. 发送
  3. Bundle bundle = new Bundle();
  4.             bundle.putSerializable("test", new SB(1,2));
  5.             Intent intent = new Intent(this, MyScreen.class);
  6.             intent.putExtras(bundle);
  7.             startActivity(intent);

接收
  1.     protected void onCreate(Bundle savedInstanceState)
  2.     {
  3.         // TODO Auto-generated method stub
  4.         super.onCreate(savedInstanceState);
  5.         setContentView(R.layout.djx2);
  6.         Bundle bundle=this.getIntent().getExtras();
  7.         s=bundle.getString("name");
  8.         SB sb=(SB)bundle.getSerializable("test");
  9.         System.out.println(sb.posy);
  10.     }
上一篇:mac os x的快捷键
下一篇:c struct java 实现