Android的活动之间传递字符串数组 [英] Passing string array between android activities
本文介绍了Android的活动之间传递字符串数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有 2字符串数组第一个活动里面 - 一个,现在我需要在两个阵列传递到second_activity - B,我该怎么办呢?
我知道在 意图
样的概念在Android和已经通过只是一个变量的值到另一个活动,但我还没有实现传递活动之间的字符串数组的概念,我已经冲浪网为相同的。
请让我知道了可能的解决方案。
解决方案
叠B =新包();
b.putStringArray(重点,新的String [] {值1,值2});
意图I =新的意图(背景下,A类);
i.putExtras(B);
希望这会帮助你。
为了阅读:
叠B = this.getIntent()getExtras()。
String []数组= b.getStringArray(密钥);
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);
这篇关于Android的活动之间传递字符串数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文