Associate two image

2

I wanted to create a app that when clicking on an image changed its image and waited to click on another image. If the two images were equal (with the same value) activate a button that gave the possibility to move to another Layout.

I only have the code to change the image.

botao.setOnClickListener(new View.OnClickListener() {

   @Override
   public void onClick(View v) {         
    if( ????????? ) 
       botao.setBackgroundResource(R.drawable.preto);                
    else
       botao.setBackgroundResource(R.drawable.verde);

}
    
asked by anonymous 06.12.2016 / 15:59

1 answer

0
  

Algorithm

  • Create an array
  • Match each pair (row and column) to an image
  • On each image click     - Check if it is click 1, if it is to change the image     - If it is click 2, reset the click counter and check if the images are the same. If they are the same, Keep the pictures facing you.     - Check if there are still images to be flipped / clicked.
  • The algorithm is this. Remember to leave the image displayed for 3 seconds if the 2 images turned do not are the same.

        
    06.12.2016 / 22:52