美文网首页
android传值和取值

android传值和取值

作者: 小重庆 | 来源:发表于2016-04-20 18:28 被阅读0次

    Intent传值

    Intent intent =newIntent(MainActivity.this,Main2Activity.class);

    intent.putExtra("name","jack");

    intent.putExtra("age",25);

    intent.putExtra("address","广州");

    Bundle bundle =newBundle();

    bundle.putString("code","1021521");

    intent.putExtra("bundle",bundle);

    startActivity(intent);

    Intent获取值并打印出来

    Intent intent = getIntent();

    String name =intent.getStringExtra("name");

    String address = intent.getStringExtra("address");

    intage = intent.getIntExtra("age",0);

    Bundle bundle = intent.getBundleExtra("bundle");

    String code = bundle.getString("code");

    Log.i("next","---name-->"+name);

    Log.i("next","---age-->"+age);

    Log.i("next","---address-->"+address);

    Log.i("next","---code-->"+code);

    相关文章

      网友评论

          本文标题:android传值和取值

          本文链接:https://www.haomeiwen.com/subject/xpzzlttx.html