简体   繁体   English

Android Bundle putStringArray不起作用

[英]Android Bundle putStringArray not working

I'm want to pass three strings from one acticity to another, but it doesn't work. 我想将三个字符串从一种方案传递到另一种方案,但这不起作用。 I've tried a lot but I just can't understand why it doesn't work this is the first activity 我已经尝试了很多,但是我不明白为什么它不起作用,这是第一次活动

First activity 第一次活动

                          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);

Second Activity 第二次活动

        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]);

it just doesn't work, any ideas of how I can fix this? 只是不起作用,关于如何解决此问题的任何想法?

您有3个元素,但为2个分配了空间。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM