Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9156899
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T12:52:53+00:00 2026-06-17T12:52:53+00:00

I got some problems using ViewGroup and a automatically generated ViewPager. I want to

  • 0

I got some problems using ViewGroup and a automatically generated ViewPager.
I want to add a View and remove a view but everytime I am trying it I get the error:

    01-20 14:05:40.028: E/AndroidRuntime(3615): FATAL EXCEPTION: AsyncTask #1
    01-20 14:05:40.028: E/AndroidRuntime(3615): java.lang.RuntimeException: An error occured while executing doInBackground()
    01-20 14:05:40.028: E/AndroidRuntime(3615):     at android.os.AsyncTask$3.done(AsyncTask.java:299)
    01-20 14:05:40.028: E/AndroidRuntime(3615):     at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:352)
    01-20 14:05:40.028: E/AndroidRuntime(3615):     at java.util.concurrent.FutureTask.setException(FutureTask.java:219)
    01-20 14:05:40.028: E/AndroidRuntime(3615):     at java.util.concurrent.FutureTask.run(FutureTask.java:239)
    01-20 14:05:40.028: E/AndroidRuntime(3615):     at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
    01-20 14:05:40.028: E/AndroidRuntime(3615):     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
    01-20 14:05:40.028: E/AndroidRuntime(3615):     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
    01-20 14:05:40.028: E/AndroidRuntime(3615):     at java.lang.Thread.run(Thread.java:856)
    01-20 14:05:40.028: E/AndroidRuntime(3615): Caused by: android.view.ViewRootImpl$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views.
    01-20 14:05:40.028: E/AndroidRuntime(3615):     at android.view.ViewRootImpl.checkThread(ViewRootImpl.java:4746)
    01-20 14:05:40.028: E/AndroidRuntime(3615):     at android.view.ViewRootImpl.requestLayout(ViewRootImpl.java:823)
    01-20 14:05:40.028: E/AndroidRuntime(3615):     at android.view.View.requestLayout(View.java:15468)
    01-20 14:05:40.028: E/AndroidRuntime(3615):     at android.view.View.requestLayout(View.java:15468)
    01-20 14:05:40.028: E/AndroidRuntime(3615):     at android.view.View.requestLayout(View.java:15468)
    01-20 14:05:40.028: E/AndroidRuntime(3615):     at android.view.View.requestLayout(View.java:15468)
    01-20 14:05:40.028: E/AndroidRuntime(3615):     at android.view.ViewGroup.removeView(ViewGroup.java:3524)
    01-20 14:05:40.028: E/AndroidRuntime(3615):     at de.tecfriends.vbtsplash2013.MainActivity$DummySectionFragment.Teilnehmer(MainActivity.java:219)
    01-20 14:05:40.028: E/AndroidRuntime(3615):     at de.tecfriends.vbtsplash2013.MainActivity$DummySectionFragment$1.onTaskCompleted(MainActivity.java:148)
    01-20 14:05:40.028: E/AndroidRuntime(3615):     at de.tecfriends.vbtsplash2013.BackgroundDownload.doInBackground(BackgroundDownload.java:38)
    01-20 14:05:40.028: E/AndroidRuntime(3615):     at de.tecfriends.vbtsplash2013.BackgroundDownload.doInBackground(BackgroundDownload.java:1)
    01-20 14:05:40.028: E/AndroidRuntime(3615):     at android.os.AsyncTask$2.call(AsyncTask.java:287)
    01-20 14:05:40.028: E/AndroidRuntime(3615):     at java.util.concurrent.FutureTask.run(FutureTask.java:234)
    01-20 14:05:40.028: E/AndroidRuntime(3615):     ... 4 more

In the Class onCreateView i set a public ViewGroup named vGroup.
At the end of all data processing i try to vGroup.removeView(vGroup.findViewById(1)); and vGroup.addView(modeList); but i get the error above.

How can I reach the original Thread where I can add and remove Views to this ViewGroup?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T12:52:54+00:00Added an answer on June 17, 2026 at 12:52 pm

    ViewRootImpl$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views. means that you are trying to access UI elements from the background thread, which is the non-UI thread.

    vGroup.removeView() should only be called from onPreExecute() or onPostExecute(), as these two functions run on the UI thread.

    private class MyAsyncTask extends AsyncTask<String, Void, String> {
    
          @Override
          protected String doInBackground(String... params) {
                .... // runs on background / non-UI thread
          }      
    
          @Override
          protected void onPostExecute(String result) {   
                ... // runs on UI thread            
          }
    
          @Override
          protected void onPreExecute() {
                ... // runs on UI thread      
          }
    
          @Override
          protected void onProgressUpdate(Void... values) {
          }
    }
    

    Documentation of AsyncTask.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm Using CakePHPs standard Auth mechanism, but I have some problems with that. Everytime
I've got some problems while trying to lay out my site. I'm using Blueprint
I got some problems in Datagrid WPF I have a datagrid, and I want
I got some strange problems when using sbt to build a simple Scala class.
I've got some issues with javascript. Which causes some problems. I'm using DevExpress MVC
After some problems solved, I got a tricky stuff. I am using an overlay
I'm trying to add the T4MVC templates to my project, but I'm experiencing some
I've got some problems using Maven on this ready-to-use project: http://wiki.javaforum.hu/display/ANDROIDSOAP/Home Basically, I just
i've got some problems using jQTouch. I have this Link <a href=#site_map class=swap>Map</a> and
I have to show some LinearLayouts in Scroll. I am using ListView but got

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.