There is an ImageButton in activity. By clicking on them, it is necessary that these pictures appear in a specially designated field. Pictures in it appear in the order in which they clicked on their originals. By clicking on the picture in the field, it disappears. What structure and how best to use to create such a field? I'm just learning and using eclipse to create an application.

    2 answers 2

    ImageView to use. For each image. Add a new ImageView to LinearLayout, and set it imageView.setImageDrawable(imageButton.getDrawable()); when you click on imageButton. When you click on imageView, simply remove it from the parent.

      1. Need a container, such as LinearLayout. You can add it to the xml markup file in advance:
        <LinearLayout android:id="@+id/conteiner" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal"/> 
      1. Further in the code, you can add images to the container, for example on onClick

         //Π½Π°Ρ…ΠΎΠ΄ΠΈΠΌ ΠΊΠΎΠ½Ρ‚Π΅ΠΉΠ½Π΅Ρ€ LinearLayout layout = (LinearLayout) findViewById(R.id.conteiner); //создаСм Π²ΠΈΠ΄ΠΆΠ΅Ρ‚ ImageView imageView = new ImageView(MainActivity.this); imageView.setImageResource(R.mipmap.ic_launcher); //добавляСм Π²ΠΈΠ΄ΠΆΠ΅Ρ‚ Π² ΠΊΠΎΠ½Ρ‚Π΅ΠΉΠ½Π΅Ρ€ layout.addView(imageView); 
      • Thanks, very helpful. If it's not difficult for you, can you say more, how to make the images added to the container from top to bottom? Used both horizontal and vertical LinearLayout, did not help. - Alena Fedorova