android--Activity值传递

intent用法:

MainActivity中

  Intent intent=new Intent(MainActivity.this,NextActivity.class);
    intent.putExtra("name", "Tom");
    intent.putExtra("age", 23);

    //学习了Bundle的用法
    Bundle bundle=new Bundle();
    bundle.putString("code", "124");
    intent.putExtra("bundle", bundle);
    startActivity(intent);

NextActivity中:

  Intent intent=getIntent();
  String name=intent.getStringExtra("name");
  Log.i(TAG, "--name->"+name);
  int age=intent.getIntExtra("age", 0);
  Log.i(TAG, "--age-"+age);
  Bundle bundle=intent.getBundleExtra("bundle");
  String code=bundle.getString("code");
  Log.i(TAG,"--code-"+code);

另外配置log的方法:

private final String TAG="NextActivity";

在window--showview--other--LogCat,create filter中,filter name:"NextActivity",by Log Tag:"NextActivity",by Log Level:info

 

posted @ 2014-02-11 20:29  一个人的秋千  阅读(202)  评论(0)    收藏  举报