android - 将二维数组传递给另一个 Activity

标签 android multidimensional-array parcelable

我如何将 2 个教派数组对象作为参数传递给另一个 Activity

如何在另一个 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");

最佳答案

您可以使用 putSerializable.数组是可序列化的。

存储:

bundle.putSerializable("list", selected_list);//这里的 bundle 是 Bundle 对象。

访问:

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

例子

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

关于android - 将二维数组传递给另一个 Activity ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12214847/

相关文章:

android - 如何在 Parcelable 类中存储 android UI 组件?

Android:可打包异常

android - android虚拟机在ubuntu系统下运行时的错误

python - 如何表示具有多个属性的数据?

c++ - 数组、 vector 、Boost::arrays

angularjs - 在多维数组的 ng-repeat 上使用 orderBy

java - Android运行时错误: Parcel unable to marshal value

android - 从图库中选择图像

java - 使用 Android NDK 获取 ANDROID_ID - 过时的本地引用错误

android - adb shell 命令 : mkdir (for creating a directory)