02-13 11:36:17.808: E/AndroidRuntime(4686): Caused by: android.view.ViewRoot$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views.`
as you are You are removing views mParentLayout.removeAllViews()
in AsyncTask's doInBackground()
method. As in android you can not manipulate UI in doInBackground() method directly.
you can manipulate(add, delete or set visibility of UI controls) UI in onPostExecute()
or onPreEcecute()
methods. As you are removing layout childs based on downloaded list.
Remove that controls on onPostExecute()
method of your AsyncTask
. You can also remove controls onProgressUpdate()
if still there is requirement to manipulate UI in doInBackground()
mthos then you must go with runOnUiThread()
Sample code :
ActivityName.this.runOnUiThread(new Runnable() {
public void run() {
// Manipulate UI here
}
});