且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何从android中的另一个活动传递字符串数组值

更新时间:2022-11-11 12:04:52

如果您创建活动然后通过调用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");