passing arrays using bundle in android

后端 未结 5 1762
没有蜡笔的小新
没有蜡笔的小新 2020-12-28 19:19

I need to pass an array of String/integer values from one Activity to another. How do I achieve this?

5条回答
  •  春和景丽
    2020-12-28 19:42

    Code for pass String And Integer value ::

    In Your First Activity ::

    Intent intent = new Intent(California.this,details.class);
    Bundle bundle = new Bundle();
    bundle.putString("Keyname1", StringValue);
    bundle.putInt("Keyname2", IntegerValue);
    intent.putExtras(bundle);
    startActivity(intent);
    

    In Second Activity :

    Bundle b=this.getIntent().getExtras();
    String s=b.getString("Keyname1");
    int i=b.getInt("Keyname2");
    

提交回复
热议问题