Hi,
You are adding the same ImageButton again and again.
You are getting reference of some existing button:
>   b = (ImageButton) findViewById(R.id.card_image);

and adding that button to the view again and again! So, you are
getting the runtime error.

Hint: You need to create NEW ImageButtons if you want multiple image
buttons.
b = new ImageButton();

Regards
Sarwar Erfan


On Nov 30, 3:18 pm, pedr0 <[email protected]> wrote:
> Hi at all,
>
> I have to put some ImageButton inside an LinearLayout, but I don't
> know the number of this statically, so because I keep the data through
> internet at run-time.
>
> I solved this problem adding new child at the layout at run time after
> the oncreate() functions is called in this way:
>
> ImageButton b;
> LinearLayout contanier = (LinearLayout)
> findViewById(R.id.card_images_layout);
> for (int i = 0; i < this.card.images.size(); i++) {
>   b = (ImageButton) findViewById(R.id.card_image);
>   b.setImageBitmap((this.card.images.get(i).getImage_data()));
>  contanier.addView(b);
>
> }
>
> But I take this error
>
> java.lang.IllegalStateException: The specified child already has a
> parent. You must call removeView() on the child's parent first
>
> Is my solution which is incorrect or I make wrong something?
>
> Thanks a lot
>
> pedr0

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to