I want to run AsyncTask named loadMore again and again in loop trigger via Button named LOAD MORE.

Error:

> 
> 03-07 20:31:38.330: E/AndroidRuntime(504): java.lang.IllegalStateException: Cannot execute task: the task has already been executed (a task can be executed only once
> 
> 
> 

Tried

* Button LOADMORE only be VISIBLE when `onPostExecute()` of loadMore - AsyncTask is executed. Adding LOADMORE view inside `onPostExecute()`.
* Assumed behaviour of AsyncTask is not coming up via LOADMORE button.
* checking whether AysncTask - loadMore RUNNING or not?? inside `onClickListener` of LOADMORE button.
* But as logging information it never reaches the `onClickListener` of LOADMORE button.

onClickListener Code of LOADMORE button::

```
 ld. . . . . .loadMore AsyncTask.
 ll. . . . . . LinearLayout (where I'm removing and Adding LOADMORE button).
 loadMore. . . LOADMORE Button.

public void onClick(View v) {
        // TODO Auto-generated method stub
        ll.removeView(loadMore);
        //loadMore.setVisibility(View.INVISIBLE);
        spin2.setVisibility(View.VISIBLE);
        if(ld.getStatus()==Status.PENDING)
        {
            ld.execute();
            Log.i("PENDING", "Not yet RUNNING");
        }
        else if(true)
        {
            while(ld.getStatus()==Status.RUNNING)
            {
                Log.i("loadMore Async", "LoadMore RUNNING");
                if(ld.getStatus()==Status.FINISHED)
                    return;
            }
            ld.execute();
        }

    }

```

---

onPostExecute() of loadMore AsyncTask ::

```
protected void onPostExecute(Void result) {
adapter = new PhotosAdapter(MainActivity.this, arrPhotos);
        gridOfPhotos.setAdapter(adapter);

        spin2.setVisibility(View.GONE);

        ll.addView(loadMore);
        Log.i("loadMore-Async", "Adding LoadMore button again");
        Log.i("loadMore-Async", "LoadMore AsyncTask onPost() finished");
        loadMore.setOnClickListener(n);
        Log.i("loadMore-Async", "Adding Listener to LoadMore");
    }

```