结果存储在arraylist中如何检索arraylist在android中添加结果

时间:2011-04-13 06:35:19

标签: android arraylist

我正在后台进程中实现同步类我得到了一些结果。这些结果存储在后执行方法的数组列表中。如何检索这些结果?

代码文件

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);

       } 
    }   

请转发一些解决方案。

1 个答案:

答案 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.
    }