当按下另一个图像视图时,如何使一个图像视图消失?

How to make one imageview disappear when another imageview is pressed?

我正在尝试制作一个枪支模拟器应用程序,每按一下枪支,一排子弹就会一颗一颗地消失。需要什么 Java 代码才能使第一次单击枪时 bullet1 消失,第二次按下枪时 bullet2 消失?

<ImageView
    android:layout_width="match_parent"
    android:layout_height="300dp"
    android:paddingBottom="6dp"
    android:src="@drawable/gun"
    android:clickable="true"
    android:id="@+id/gunimage"
    android:onClick="shoot"/>

<ImageView
    android:layout_width="30dp"
    android:layout_height="wrap_content"
    android:src="@drawable/bullet"
    android:id="@+id/bullet1"/>

<ImageView
    android:layout_width="30dp"
    android:layout_height="wrap_content"
    android:src="@drawable/bullet"
    android:id="@+id/bullet2"/>

试试这个方法

firstbullet.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    // TODO Auto-generated method stub
                    secondbullet..setVisibility(View.GONE);
                }
            });

    secondbullet.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    // TODO Auto-generated method stub
                    firstbullet..setVisibility(View.GONE);
                }
            });