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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T05:02:56+00:00 2026-05-26T05:02:56+00:00

That is my code… for(int i=0;i<sitesList.getPdf().size();i++) { Bitmap bmp; URL url=null; InputStream is; ImageView

  • 0

That is my code…

for(int i=0;i<sitesList.getPdf().size();i++)
    {
        Bitmap bmp;
        URL url=null;
        InputStream is;
        ImageView iv=null;

        tr=new TableRow(this);
        tr.setLayoutParams(new LayoutParams(
                LayoutParams.WRAP_CONTENT,
                LayoutParams.WRAP_CONTENT));

        for (int j=0;j<2;j++)
        {
            iv=new ImageView(this);
            try
            {
                s1=sitesList.getThumbnail().get(count);
                url = new URL(s1);
                count++;

                 conn=(HttpURLConnection)url.openConnection(); 
                 conn.setDoInput(true);
                 conn.connect();

                  is = conn.getInputStream();

                 bmp = BitmapFactory.decodeStream(is); 
                 iv.setImageBitmap(bmp);

                    iv.setLayoutParams(new LayoutParams(
                            LayoutParams.FILL_PARENT,
                            LayoutParams.FILL_PARENT));
                    iv.setId(ids);
                    int flag=iv.getId();
                    Log.v(".....Flag.....",+flag+"");

                    tr.addView(iv);

                    tl.addView(tr,new TableLayout.LayoutParams(
                            LayoutParams.FILL_PARENT,
                            LayoutParams.WRAP_CONTENT));

                    ids++;
                    Log.v(".....Counter...",count+"");
                    iv.setOnClickListener(new View.OnClickListener() 
                    {

                        public void onClick(View v) 
                        {


                            int a=v.getId();
                            if(a==0)
                            {
                                Toast.makeText(getApplicationContext(), "0",Toast.LENGTH_SHORT).show();
                            }
                            else if(a==1)
                            {
                                Toast.makeText(getApplicationContext(), "1",Toast.LENGTH_SHORT).show();
                            }
                            else if(a==2)
                            {
                                Toast.makeText(getApplicationContext(), "2",Toast.LENGTH_SHORT).show();
                            }
                            else if(a==3)
                            {
                                Toast.makeText(getApplicationContext(), "3",Toast.LENGTH_SHORT).show();
                            }
                            else if(a==4)
                            {
                                Toast.makeText(getApplicationContext(), "4",Toast.LENGTH_SHORT).show();
                            }
                            else if(a==5)
                            {
                                Toast.makeText(getApplicationContext(), "5",Toast.LENGTH_SHORT).show();
                            }

                        }
                    });     

            }catch(Exception e)
            {
                e.printStackTrace();
            }
        }

        //Log.v(".....Myids",ids+"");
        //ids++;
    }

it will show me (1)”The specified child already has a parent” warning
and (2) when i click image it will recognize only 0,1,2 on the toast.

can anyone help me.thanks in advance

Regards

arpit

  • 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-26T05:02:57+00:00Added an answer on May 26, 2026 at 5:02 am

    In your inner for loop which loops for 0,1 i.e 2 times.

    In this inner loop you are adding same tr(tablerow) to tl(tablelayout) twice hence it is giving specified child has already parent warning.

    You not manipulating ids variable properly hence you are getting toast for only 0,1,2, iv.setId(ids); Since inner loop repeats only twice check you ids variable.

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

Sidebar

Related Questions

I have that code : while(!lastPage && currentPage < maxPageSize){ StringBuilder request = new
Example: That code is run each time, when the listAdapter requests a new row:
I have heard people state that Code Generators and T4 templates should not be
I don't understand why authors said that Code Listing 9.1 from Programming in Scala
What Visual Studio settings and .emacs macros improve the likelihood that code written on
I need to move .NET code to the Compact Framework. That code uses HttpUtility.UrlEncode
For a university assignment in Java the specification requires that Code Listings: in 10-point
I'm about to write a Wrapper for a COM interop IStream so that code
I really enjoyed Jeff's post on Spartan Programming . I agree that code like
The code that I want to write is like this: void MethodOnThreadA() { for

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.