2 回答
TA贡献2019条经验 获得超9个赞
尝试这个。在第一个活动中:
String sFirstname = "Tope";
String sLastname = "Adebodun";
Intent theIntent = new Intent(MainActivity.this, ReceivingActivity.class);
theIntent.putExtra("firstname", sFirstname);
theIntent.putExtra("lastname", sLastname);
然后在第二个活动中,在 onCreate 方法中执行以下操作:
Intent intent = getIntent();
String thefirst = (String) intent.getExtras.getString("firstname");
String thelast = (String) intent.getExtras.getString("lastname");
TA贡献1878条经验 获得超4个赞
我不想使用getExtras所以你应该有两个getExtra 像这样的:
Intent intent = getIntent();
String ssurname = intent.getExtra("surname");
String slastname = intent.getExtra("lastname");
firstname.setText(ssurname);
lastname.setText(slastname);
添加回答
举报