gpt4 book ai didi

java - 将2个变量传递给passedView

转载 作者:行者123 更新时间:2023-12-01 06:11:00 24 4
gpt4 key购买 nike

我似乎无法理解这一点。我试图将两个字符串传递给一项新 Activity ,但只能传递一个字符串。有人可以帮忙吗?我希望传递的字符串表示“我想要” movieName movieGroup “everyday”

public class Main22Activity extends AppCompatActivity {
String passedVar=null;
private TextView passedView= null;


@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main22);
Bundle extras = getIntent().getExtras();
passedVar=getIntent ().getStringExtra(MainActivity.ID_EXTRA + "movieName");
passedVar2=getIntent ().getStringExtra(MainActivity.ID_EXTRA + "movieGroup");
passedView = (TextView) findViewById(R.id.textView3);
passedView.setText("I would like " + passedVar, passedVar2 + "everyday");


}

最佳答案

public class Main22Activity extends AppCompatActivity {
String passedVar=null;
String passedVar2=null;
private TextView passedView= null;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main22);
Bundle extras = getIntent().getExtras();
passedVar=getIntent ().getStringExtra(MainActivity.ID_EXTRA +"movieName");
passedVar2=getIntent ().getStringExtra(MainActivity.ID_EXTRA + "movieGroup");
passedView = (TextView) findViewById(R.id.textView3);
passedView.setText("I would like " + passedVar + "," + passedVar2 + "everyday");
}

注意变化

passedVar + "," + passedVar2 

关于java - 将2个变量传递给passedView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34617385/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com