android - 将 ArrayList<Double> 从一个 Activity 传递到 android 上的另一个 Activity

标签 android

我已经存储了 ArrayList<Double>在我的 bean 类上,

我的主要 Activity 有 bean 类,

如何传递ArrayList<Double> , 从我的主要 Activity 到另一个 Activity 。?

我的数组列表是双重的。如何传递双数组列表?

最佳答案

这个可以帮助你...

public Intent putParcelableArrayListExtra (String name, ArrayList<? extends Parcelable> value)

有关更多信息,请查看 putParcelableArrayListExtra

编辑:

如果你有一个 double[] 那么你可以使用

void putDoubleArray(String key, double[] value) Bundle类..

将 double 组值插入到此 Bundle 的映射中,替换给定键的任何现有值。 并将此包传递给 Intent to Other Activity。

更新:2

第一 Activity :

Intent intent = new Intent(this, OtherActivity.class);
ArrayList<Double> listDouble = new ArrayList<Double>();
listDouble.add(1111.00000);
listDouble.add(13331.00000);
intent.putExtra("arraylist", listDouble);
startActivity(intent);

OtherActivity:(检索双数组列表)

ArrayList<Double> listDouble = (ArrayList<Double>) getIntent().getSerializableExtra("arraylist");
System.out.println("...serialized data.." + listDouble);

关于android - 将 ArrayList<Double> 从一个 Activity 传递到 android 上的另一个 Activity ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11648312/

相关文章:

java - 我正在使用VideoView在我的应用程序中显示视频,但我不明白如何使pause()和resume()函数正常工作

android - 如何在 Flutter 中更改蓝牙设备名称?

android - 通知中的 Intent 不会改变

android - 在 onCreate() 中遇到致命异常

android - 在 fragment android 中的 CursorLoader 中显示进度对话框

java - 如何从我的字符串中一一检索值

android - TextView 使用 constraintLayout 离开屏幕

android - 在 Android Studio 中将 T-API (Opencv 3.0) 与 OpenCL 结合使用 无速度改进

android - 我可以在 Corona 中使用麦克风吗?

android - 如何在 cocos2d-x 中使用 SimpleaudioEngine 的 pitch, pan, gain 选项