美文网首页
a正向传值

a正向传值

作者: 芥子劫 | 来源:发表于2016-08-15 18:09 被阅读0次

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

    Bundle bd =newBundle();

    bd.putString("username",nameTF.getText().toString());

    bd.putString("password",passwordTF.getText().toString());

    it.putExtras(bd);

    startActivity(it);

    TextView tv = (TextView)findViewById(R.id.textView);

    Button btn = (Button)findViewById(R.id.button2);

    Intent it = getIntent();

    Bundle bd = it.getExtras();

    String s = bd.getString("username");

    tv.setText(s);

    btn.setOnClickListener(newView.OnClickListener() {

    @Override

    public voidonClick(View view) {

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

    startActivity(it2);

    }

    });

    }

    相关文章

      网友评论

          本文标题:a正向传值

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