SHARE
TWEET

Untitled

a guest Dec 24th, 2018 106 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import android.content.Intent;
  2. import android.support.v7.app.AppCompatActivity;
  3. import android.os.Bundle;
  4. import android.view.View;
  5. import android.view.View.OnClickListener;
  6. import android.widget.Button;
  7. import android.widget.ImageView;
  8.  
  9. public class SelectActivity extends AppCompatActivity {
  10.     @Override
  11.     protected void onCreate(Bundle savedInstanceState) {
  12.         super.onCreate(savedInstanceState);
  13.         setContentView(R.layout.select);
  14.  
  15.         Button btn;
  16.         btn = findViewById(R.id.button_resultados);
  17.         btn.setOnClickListener(new OnClickListener() {
  18.             @Override
  19.             public void onClick(View v) {
  20.                 Intent intent = new Intent(v.getContext(), ResultadosActivity.class);
  21.                 startActivityForResult(intent, 0);
  22.             }
  23.         });
  24.     }
  25.     public void onClick() {
  26.         ImageView mypic1 = (ImageView) findViewById(R.id.select1);
  27.         ImageView mypic2 = (ImageView) findViewById(R.id.select2);
  28.         ImageView mypic3 = (ImageView) findViewById(R.id.select3);
  29.         ImageView mypic4 = (ImageView) findViewById(R.id.select4);
  30.         ImageView mypic5 = (ImageView) findViewById(R.id.select5);
  31.         ImageView mypic6 = (ImageView) findViewById(R.id.select6);
  32.  
  33.         View.OnClickListener listener= new OnClickListener() {
  34.             public void onClick(View imageView) {
  35.                 if(imageView instanceof ImageView ){
  36.                     if(imageView.getTag().equals(1)){
  37.                         ((ImageView) imageView).setImageResource(R.drawable.oldpic);
  38.                         imageView.setTag(2);
  39.                     }else{
  40.                         ((ImageView) imageView).setImageResource(R.drawable.newpic);
  41.                         imageView.setTag(1);
  42.                     }
  43.                 }
  44.             }
  45.         };
  46.         mypic1.setOnClickListener(listener);
  47.         mypic2.setOnClickListener(listener);
  48.         mypic3.setOnClickListener(listener);
  49.         mypic4.setOnClickListener(listener);
  50.         mypic6.setOnClickListener(listener);
  51.         mypic6.setOnClickListener(listener);
  52.     }
  53. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top