将2个变量传递给passView

时间:2016-01-05 17:11:15

标签: java string

我似乎无法得到这个。我正在尝试将两个字符串传递给一个新活动,但只能传递一个。有人可以帮忙吗?我希望传递的字符串能说“我想要”movieName movieGroup“每天”

{{1}}

1 个答案:

答案 0 :(得分:-1)

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