通过二维数组到另一个活动 [英] Pass 2D array to another Activity

查看:178
本文介绍了通过二维数组到另一个活动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何通过2宗派数组对象作为参数传递给另一个活动

如何获取二维数组字符串值在另一个活动

 的String [] []海峡;

    意图L =新的意图(背景下,AgAppMenu.class);
                 l.putExtra(味精,STR);
                 l.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                 context.startActivity(升);



  另一个活动类

   的String [] [] xmlRespone2;

    xmlRespone2 = getIntent()getExtras()的getString(味精)。
 

解决方案

您可以使用<一个href="http://developer.android.com/reference/android/os/Bundle.html#putSerializable%28java.lang.String,%20java.io.Serializable%29">putSerializable.数组是序列化的。

要保存的内容:

bundle.putSerializable(名单,selected_list); //这包是捆绑对象

要访问:

 的String [] [] passedString_list =(字符串[] [])bundle.getSerializable(名单);
 

示例

 意图mIntent =新的意图(这一点,Example.class);
捆绑mBundle =新包();
mBundle.putSerializable(名单,selected_list);
mIntent.putExtras(mBundle);
 

how do i pass 2 denominational array object as a parameter to another activity

how to get two dimensional array string value in another activity

   String [][]str;

    Intent l = new Intent(context,AgAppMenu.class);
                 l.putExtra("msg",str);
                 l.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);   
                 context.startActivity(l);



  another Activity class

   String[][] xmlRespone2;

    xmlRespone2 = getIntent().getExtras().getString("msg");

解决方案

You can use putSerializable. Arrays are serializable.

To store:

bundle.putSerializable("list", selected_list); // Here bundle is Bundle object.

To access:

String[][] passedString_list = (String[][]) bundle.getSerializable("list");

Example

Intent mIntent = new Intent(this, Example.class);
Bundle mBundle = new Bundle();
mBundle.putSerializable("list", selected_list);
mIntent.putExtras(mBundle);

这篇关于通过二维数组到另一个活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆