views:

165

answers:

1

private class Task_xmlparse extends AsyncTask { private final ProgressDialog dialog = new ProgressDialog(BlackSheepimage.this); protected void onPreExecute() { this.dialog.setMessage("Loading..."); this.dialog.setCancelable(false); this.dialog.show(); }

    @Override
    protected Void doInBackground(String... params)
    {
        try {

            DomFeedParser dom = new DomFeedParser(url);
            Log.v("thread"," "+url);
            List<Message_thbnail> l_obj_tnail = new ArrayList<Message_thbnail>();
            List<Message_zoom> l_obj_zoom = new ArrayList<Message_zoom>();
            l_obj_tnail = dom.parse_tnail();
            l_obj_zoom = dom.parse_zoom();
            VAL1 = new String[l_obj_tnail.size()];
            VAL2= new String[l_obj_zoom.size()];
            //Log.v("bufersize",""+bufferarray.length);
            //Log.v("val2Length",""+VAL1.length);
            Iterator<Message_thbnail> it_tnail = l_obj_tnail.iterator();
            while (it_tnail.hasNext())
            {
                k++;
                Log.v("Zoo",""+zo);
                VAL1[k] = it_tnail.next().toString();
                bufferarray[zo]=VAL1[k];
                Log.v("Buffer",bufferarray[zo]);
                zo++;


            }
            Log.v("threadbuffsize",""+zo);
            Iterator<Message_zoom> it_zoom = l_obj_zoom.iterator();
            Log.v("zoosize", ""+l_obj_zoom.size());
            while (it_zoom.hasNext()) {
                k1++;

                Log.v("Zoo1",""+zo1);
                VAL2[k1] = it_zoom.next().toString();
                zoombufferarray[zo1]=VAL2[k1];
                zo1++;
                Log.v("tag",VAL2[k1].toString());

            }

            thumbnail_disp=bufferarray;
            grid= new GridAdapter(BlackSheepimage.this,bufferarray);
        } catch (Exception e) {
            //Log.v("Image", "dom" + e);
        }

        return null;
    }


protected void onPostExecute(Void result) {

    lay2_gv.setAdapter(grid);
    if (this.dialog.isShowing()) {
        this.dialog.dismiss();
    }
}

}

public void onCreate(Bundle savedInstanceState) { url="http://www.theblacksheeponline.com/partypics.php?page="+pageno; super.onCreate(savedInstanceState); lay2_gv = (GridView) findViewById(R.id.jr_lookbook_grid); new Task_xmlparse().execute(url); tv = (TextView) findViewById(R.id.next_pg); tv.setOnClickListener(this) ; lay2_gv.setOnItemClickListener(this); } public void onClick(View arg0) {

        pageno++;
        Log.v("pge",""+pageno);
        lay2_gv.setVisibility(GridView.GONE);
        url="http://www.theblacksheeponline.com/partypics.php?page="+pageno;
        //Log.v("URL",url);
         new Task_xmlparse().execute(url);

}
A: 

I don't think using Intent is the right thing for you here. As I gather it, you parse an xml to display images and you want to be able to add more images when users click on a button. So here is what you need to do :

in the onClick method of your button, you should start an AsyncTask or a background Thread, in which you make an http request on your url.

This will get you the xml of the next images, you parse it and prepare the images in your background Thread.

Then back in your main Thread (in onClick method for instance), you grab these images, add them to the adapter of your GridView and call notifyDataSetChanged() to update your GirdView. And that should do the trick.

Sephy
hi i followed your concept but now i call AsyncTask in button click url was changed and call Asynctask and pass url when i click button but did not reflect output in gridview,gridview display first 16 images was display in gridview what can i do How solve this problem
sivaraj
Please try to use punctuation in yours sentences, it's really hard to understand you. And well, with just your comment, I can't help you, you need to detail more. Add some code to your post, you might be doing something wrong in your AsyncTask.
Sephy
public void onClick(View arg0) { pageno++; lay2_gv.setVisibility(GridView.GONE); url="http://www.theblacksheeponline.com/partypics.php?page="+pageno; new Task_xmlparse().execute(url); lay2_gv.setVisibility(GridView.VISIBLE); }This code i used for click method,but i did not get more image in gridgiew..
sivaraj
please edit your first post and put the full code from the onclick method AND the AsyncTask
Sephy