a正向传值

2016-08-15  本文已影响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);

}

});

}

上一篇下一篇

猜你喜欢

热点阅读