实现页面跳转
Intent intent1 = new Intent(Login.this,DataGetActivity.class);
//new Intent(currentActivity.this,targetActivity.class);
startActivity(intent1);
实现页面跳转,同时获取原先页面信息,传给target页面
ex:
currentActivity里面读取用户名username,在targetActivity里面用
currentActivity:
EditText username = (EditText) findViewById(R.id.username);
//获取目标id
Bundle bundle = new Bundle();
bundle.putString("username", username.getText().toString());
//将目标id的目标信息以键值对的形式存储
Intent intent1 = new Intent(Login.this,DataGetActivity.class);
intent1.putExtras(bundle);
//传入intent
startActivity(intent1);
targetActivity
TextView username = (TextView) findViewById(R.id.usernameInfo);
String data = "";
Bundle extras = getIntent().getExtras();
if(extras != null){
data = extras.getString("username");
}
username.setText(data);