如何从android中的另一个活动传递字符串数组值 [英] how to pass string array values from another activity in android
本文介绍了如何从android中的另一个活动传递字符串数组值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在android中的另一个活动中获取字符串
public static final 字符串 [] titles = new 字符串 [] { lollypop ,
Kitkat, Jelly was};
解决方案
如果您创建活动然后通过调用intent的putExtra()方法将数据传递给您创建的intent。然后在你的新活动中调用getIntent()。getExtras()
发送数据:
意图意图= new Intent();
final String [] titles = new 字符串 [] { lollypop,
Kitkat, Jelly Been};
intent.putExtra( titles,titles);
startActivity(intent);
接收数据:
Intent intent = getIntent();
String [] titles = intent.getStringArrayExtra( 标题跨度>);
how to get string in another activity in android
public static final String[] titles = new String[] { "lollypop",
"Kitkat", "Jelly Been" };
解决方案
If you create the activitye then pass the data to the intent you create by calling the putExtra() method of the intent. Then in your new activity call getIntent().getExtras()
Send data:
Intent intent = new Intent(); final String[] titles = new String[] { "lollypop", "Kitkat", "Jelly Been" }; intent.putExtra("titles", titles); startActivity(intent);
Receive data:
Intent intent = getIntent(); String[] titles = intent.getStringArrayExtra("titles");
这篇关于如何从android中的另一个活动传递字符串数组值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文