2
我想从一个acticity传递三个字符串到另一个,但它不起作用。我已经尝试了很多,但我只是不明白为什么它不工作 这是第一个活动Android捆绑putStringArray不工作
第一项活动
String[] g = new String[3];
g[0] = "information 1";
g[1] = "information 2";
g[2] = "information 3";
Intent intent = new Intent(Entradas.this,Informacoes.class);
Bundle bundle = new Bundle();
bundle.putStringArray("some string",g);
intent.putExtras(bundle);
startActivity(intent);
次活动
Bundle bundle = getIntent().getExtras();
String[] abc = bundle.getStringArray("some string");
TextView txtInfo= (TextView) findViewById(R.id.textViewInfo);
txtInfo.setText(abc[0]);
TextView txtNome= (TextView) findViewById(R.id.textViewNome);
txtNome.setText(abc[1]);
TextView txtPreco= (TextView) findViewById(R.id.textViewPreco);
txtPreco.setText(abc[2]);
它只是不工作,我怎么能解决这个问题的任何想法?
String [] g = new String [3]; – waqaslam
而这段代码没有崩溃?在线:g [2] =“信息3”;有趣的... – yahya
你能确切地说*如何*它不起作用?你得到什么,哪些错误... – davidcesarino