Skip to content Skip to sidebar Skip to footer

Illegalstateexception In Asynctask

I have an AsyncTask. protected class InitTask extends AsyncTask { View eachLayout; @Override protected String doInBackgrou

Solution 1:

Try following:

@OverrideprotectedvoidonProgressUpdate(Integer... values) {
        super.onProgressUpdate(values);

       if( ((LinearLayout) eachLayout.getParent()) != null 
                &&  eachLayout != null) {
             ((LinearLayout) eachLayout.getParent()).removeView(eachLayout);
       }

        linearLayout.addView(eachLayout, params);
        linearLayout.invalidate();
    }

Solution 2:

First time you add your eachLayout to some view it's OK. But when you do the same thing second time, eachLayout is already has parent. So attempt to add it to any view will fail. Try Chintan Raghwani's suggestion.

Post a Comment for "Illegalstateexception In Asynctask"