我正在后台进程中实现同步类我得到了一些结果。这些结果存储在后执行方法的数组列表中。如何检索这些结果?
代码文件
public class DownLoanPhoto extends AsyncTask
{
protected void onPreExecute()
{
super.onPreExecute();
}
protected Object doInBackground(Object... params)
{
ArrayList hhh=new ArrayList();
hhh.add(PersonImage);
hhh.add(layoutmsg);
hhh.add(personName);
hhh.add(msgImage);
hhh.add(layoutPersonImage);
Bundle bbb=new Bundle();
bbb.putStringArrayList("val", hhh);
onPostExecute(bbb);
}
return params;
}
@Override
protected void onPostExecute(Object result)
{
//How to retrieve that array list results?
layoutPersonImage.addView(msgImage);
layoutPersonImage.addView(PersonImage);
layoutPersonImage.addView(personName);
ll1.setBackgroundResource(R.drawable.tabmessage);
ll1.setGravity(Gravity.CENTER);
ll1.addView(layoutPersonImage);
((LinearLayout)findViewById(R.id.LinearlayoutMessage)).addView(ll1);
}
}
请转发一些解决方案。
答案 0 :(得分:2)
无需在onPostExecute
中调用doInBackground
,系统会自动调用它。
@Override
protected ArrayList<String> doInBackground(Void... url) {
ArrayList<String> list=null;
//Now manipulate your code get the right list
return list;
}
// -- called as soon as doInBackground method completes
@Override
protected void onPostExecute(ArrayList<String> list) {
//Your ui code.
}