通过android传递数组
我试图将一个双精度数组和一个长数组从一个活动传递到另一个活动。我也在传递一根线。字符串已成功传递,但数组未成功传递-这可能很简单,但我就是看不到 我只需点击带有以下代码的按钮即可从一个活动移动到另一个活动:通过android传递数组,android,android-intent,Android,Android Intent,我试图将一个双精度数组和一个长数组从一个活动传递到另一个活动。我也在传递一根线。字符串已成功传递,但数组未成功传递-这可能很简单,但我就是看不到 我只需点击带有以下代码的按钮即可从一个活动移动到另一个活动: Intent intent = new Intent(stockDownload.this, StockDisplay.class); //need to find a way to access information re
Intent intent = new Intent(stockDownload.this, StockDisplay.class);
//need to find a way to access information referring to specific button - stock return and name
ArrayList<Double> returnsforintent = (ArrayList<Double>) stockprices.get(view.getId());
ArrayList<Long> errortrial = datesintent;
Double[] returnstopass= returnsforintent.toArray(new Double[returnsforintent.size()]);
Long[] datestopass = datesintent.toArray(new Long[datesintent.size()]);
intent.putExtra(GRAPHRETURNS, returnstopass)
;
intent.putExtra(GRAPHSTOCKS, stocks.get(view.getId()));
intent.putExtra(GRAPHDATES, datestopass);
startActivity(intent);
你可以用
1. void putDoubleArray(String, double[]) //for passing array
2. double [] getDoubleArray(String) //for retriving array
在Bundle类中
在您的例子中,我认为double[]
(原语类型double)和double[]
(对象数组)正在产生问题。(Long[]和Long[]也是如此)
As方法需要参数作为
double[]
而不是double[]
谢谢。这是双重与双重的区别。最后,我通过intent传递了一个ArrayList,然后像这样接收它:ArrayList stockpricedownload=(ArrayList)intent.getSerializable(stockDownload.GRAPHRETURNS);
1. void putDoubleArray(String, double[]) //for passing array
2. double [] getDoubleArray(String) //for retriving array