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 6323221
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T16:28:38+00:00 2026-05-24T16:28:38+00:00

I have a ViewFlipper in which I want to add Views (Relative Layout with

  • 0

I have a ViewFlipper in which I want to add Views (Relative Layout with Children). I am trying to do this in an AsyncTask.

Here is the code I am using:

class LoadData extends AsyncTask<Object, Void, String>
{
    RelativeLayout rl_main;

    @Override
    protected void onPreExecute()
    {
        super.onPreExecute();           
    }

    @Override
    protected String doInBackground(Object... parametros)
    {   
        Cursor cur_channel = db_Helper.sqlDB.query(DatabaseHelper.Channels_TableName, null, null, null, null, null, null);
        startManagingCursor(cur_channel);

        int index = 0;
        while(cur_channel.moveToNext())
        {

            LayoutInflater inflater = getLayoutInflater();
            rl_main = (RelativeLayout) inflater.inflate(R.layout.newslisting,null); 

            ListView lv_Listing = (ListView) rl_main.findViewById(R.id.id_lv_news_listing);
            LazyAdapter newsAdpater = new LazyAdapter(NewsListing.this, channel_id, db_Helper);
            lv_Listing.setAdapter(newsAdpater);
            lv_Listing.setDividerHeight(0);

            TextView tv_channelNumber = (TextView)rl_main.findViewById(R.id.id_tv_ChannelNumber);
            if(tv_channelNumber != null)
            {
                tv_channelNumber.setText("Some Text");
            }

            TextView tv_channelName = (TextView)rl_main.findViewById(R.id.id_tv_ChannelName);
            if(tv_channelName != null)
            {
                tv_channelName.setText("Some Text");
            }

            lv_Listing.setOnItemClickListener(new OnItemClickListener()
            {

                @Override
                public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3)
                {
                    // something on ListItem Click
                }
            });         

            publishProgress();
            index++;
        }       
        return null;
    }

    @Override
    protected void onProgressUpdate(Void... v) 
    {

        super.onProgressUpdate(v);
        try
        {
            viewFlipper.addView(rl_main);  // Here I get the exception, but not on all the views
        } 
        catch (Exception e)
        {
             // Exception
        }
    }

    @Override
    protected void onPostExecute(String result)
    {
        super.onPostExecute(result);
        progressDialog.dismiss();
    }
}

In protected void onProgressUpdate(Void… v), I get the exception when I add the view to ViewFlipper, but I don’t see this Exception on every addition of View. The Exception is:

java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first. in viewflipper
  • 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-05-24T16:28:39+00:00Added an answer on May 24, 2026 at 4:28 pm

    Replacing AsyncTask with a Thread and Handler did the work. Its working perfect now. I don’t know what was the problem with AsyncTask.

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

Sidebar

Related Questions

I'm trying to add multiple Views to a ViewFlipper, which is in an AppWidget
I have a viewflipper that I want to populate with the same layout multiple
I have a ViewFlipper which has some 10 views in it and each view
I have a ViewFlipper which holds a single ImageView. i want to be able
I have add a ViewFlipper in which has 2 linearlayout,and I have made an
I have a two layout in a ViewFlipper which contains ScrollView in each of
I have a viewFlipper which flips between many textViews. For some reason the views
I have a ViewFlipper with many images. I add images to ViewFlipper like this
I have two views in my ViewFlipper . One of views contains a ListView
have written this little class, which generates a UUID every time an object of

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.