mln_ndh 0 Newbie Poster

Hello I'm new to android development. So I've tried this coding where when I clicked on the imageview it will change to another image. And it's working perfectly. But I have 10 imageview. And every time each of the image being click it will change to another image. Is there any simpler code to be use on 10 imageview? How can I do it? Thanks :)

package com.example.subtraction;


import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;

public class Level_1 extends Activity {
private ImageView imageOne=null;
private ImageView imageTwo=null;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_level_1);

    imageOne = (ImageView)findViewById(R.id.image);
    imageTwo = (ImageView)findViewById(R.id.newImage);

    imageOne.setOnClickListener(new OnClickListener()
    {
        public void onClick (View view)
        {
            imageTwo.setVisibility(View.VISIBLE);
            view.setVisibility(View.GONE);
        }
    });

    imageTwo.setOnClickListener(new OnClickListener()
    {
        public void onClick(View view)
        {
            imageOne.setVisibility(View.VISIBLE);
            view.setVisibility(View.GONE);
        }
    });
}
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.