0
所以我有一个片段x.java
和一个AsyncTask类BackgroundDataExtractor(作为两个独立的java文件)。该片段类包含这一段代码:如何从Android中的AsynTask类返回一些东西(精确到ArrayList)?
BackgroundDataExtractor backgroundWorker = new BackgroundDataExtractor(getActivity(),items);
backgroundWorker.execute(name);
其中变量items
处于x
类中定义的全球ArrayList<CustomClass>
。
我想BackgroundDataExtractor类添加/更新元素到items
(它位于片段x
)。
我目前拥有的是:
@Override
protected void onPostExecute(final String result) {
if(!result.contains("Could not fetch items")) {
dialog.dismiss();
String[] resultSplit = result.split(" ");
for(int i=1; i<resultSplit.length; i++) {
String[] tempStringArray = resultSplit[i].split(";");
items.add(new itemClass(tempStringArray[1],tempStringArray[2],tempStringArray[6],tempStringArray[3],tempStringArray[4],Double.parseDouble(tempStringArray[7])));
}
}
else {
xxxxxx
}
}
但是,这并不在该片段中x
更新items
变量。
有关如何完成此任务的任何提示?