Android的活动之间传递字符串数组数组、字符串、Android

2023-09-11 20:22:15 作者:℡稚嫩的少年.。

我有 2字符串数组第一个活动里面 - 一个,现在我需要在两个阵列传递到second_activity - B,我该怎么办呢?

我知道在 意图 样的概念在Android和已经通过只是一个变量的值到另一个活动,但我还没有实现传递活动之间的字符串数组的概念,我已经冲浪网为相同的。

请让我知道了可能的解决方案。

解决方案

 叠B =新包();
b.putStringArray(重点,新的String [] {值1,值2});
意图I =新的意图(背景下,A类);
i.putExtras(B);
 

希望这会帮助你。 为了阅读:

 叠B = this.getIntent()getExtras()。
String []数组= b.getStringArray(密钥);
 

Android C NDK中如何操作字符串数据类型呢

I am having 2 String arrays inside First Activity - A , now i need to pass both the arrays to the second_activity - B, how do i do it ?

I know about the Intent kind of concept in Android and already passed just single variable value to another activity, but i haven't implement the concept of passing string arrays between activities, i have already surfed net for the same.

pls let me know about the possible solution.

解决方案

Bundle b=new Bundle();
b.putStringArray(key, new String[]{value1, value2});
Intent i=new Intent(context, Class);
i.putExtras(b);

Hope this will help you. In order to read:

Bundle b=this.getIntent().getExtras();
String[] array=b.getStringArray(key);

 
精彩推荐
图片推荐