【发布时间】:2020-04-29 03:22:53
【问题描述】:
所以我将一个数组从一个活动传递到另一个活动, 当我将数组发送到其他活动时,我想将数组分解为各种字符串。 例如:
在第一个活动中:
array[] x = [car,ball,mouse,shirt]
在第二个活动中:
接收 x array[] ,然后将其分解为:
string one = "car"
string two = "ball"
string three = "mouse"
string four = "shirt"
例如,我可以对其中的每一个单独使用 Toast 操作。
这是我的实际代码:
头等舱:
Bundle b=new Bundle();
b.putStringArray("key",new String[]{repeat,temp,humidit,activer,food});
Intent i=new Intent(recruiter.this, StructureClass.class);
i.putExtras(b);
二等:
Bundle b = this.getIntent().getExtras();
final String[] array= b.getStringArray("key");
Toast.makeText(StructureClass.this, "i want the string to be shown here
separately for each value! " , Toast.LENGTH_LONG).show();
【问题讨论】:
-
把你的字符串改成这样
new String[]{"repeat","temp","humidit","activer","food"};
标签: java android arrays string