Has to erase Imagebutton

Asked

Viewed 33 times

1

I’m creating several ImageButton

 ImageButton imageButton = (ImageButton) LayoutInflater.from(this).inflate(R.layout.imagebutton, null);
            imageButton.setImageBitmap(bMap);

            layoutC.addView(imageButton);

I was wondering if you could remove them from the layout.

  • imageButton.setVisible(View.'unvisible.') serves?

  • I guess not because I think there’s gonna come a time when there’s gonna be a lot of repeats there

1 answer

2


You will need to report an ID for each ImageButton.

ImageButton imageButton = (ImageButton) LayoutInflater.from(this).inflate(R.layout.imagebutton, null);
imageButton.setImageBitmap(bMap);
imageButton.setID(id_do_seu_imageButton);

ImageButton imageButton = (ImageButton) layoutC.findViewById(R.id.id_do_seu_imageButton);
((LinearLayout) imageButton.getParent()).removeView(imageButton);
  • more ai picks up all the imagebutton that has in the layout

  • For this you give an id for each ImageButton or stores all of them in an array

  • I put the id on each one , as I catch it?

  • updated the answer, otherwise it would be using Maps that would be almost the same way. How do you generate these Uttons and how do you remove them? depends on the flow of your program....

  • I’m generating them after I pick up the images of them from the internet , there was doing in onResume , but thinking a better place or even a better way to create them to not have to delete , only insert the missing , pq type update on the internet how many buttons are ai insert only the new ones if you have any created leave them, I would

  • Antony just to not create another question , when I create a la button in xml I can put onClick to create a method to be called with it and clicked , as I do this way that creating?

  • Use imageButton.setOnClickListener(...)

Show 2 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.