Java Android Bundle putStringArray不工作
我想将三个字符串从一个活动传递到另一个活动,但它不起作用。我试了很多,但我就是不明白为什么它不起作用 这是第一个活动 第一项活动Java Android Bundle putStringArray不工作,java,android,bundle,Java,Android,Bundle,我想将三个字符串从一个活动传递到另一个活动,但它不起作用。我试了很多,但我就是不明白为什么它不起作用 这是第一个活动 第一项活动 String[] g = new String[3]; g[0] = "information 1"; g[1] = "information 2"; g[2] = "information 3";
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];
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]);
它根本不起作用,你知道我该如何解决这个问题吗?你有三个元素,但分配了两个元素的空间。已尝试先修复此问题?但此代码没有崩溃?在线:g[2]=“信息3”;有意思…你能确切地告诉我它是怎么不起作用的吗?你得到了什么,哪些错误。。。