SHARE
TWEET

Untitled

a guest Nov 15th, 2017 59 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. static int [] imageid ={
  2.     R.drawable.ts1,
  3.     R.drawable.ts2,
  4.     R.drawable.ts3,
  5.     R.drawable.ts4,
  6.     R.drawable.ts5,
  7.     R.drawable.ts6,
  8. };
  9.  
  10. static int [] imageidgr ={
  11.     R.drawable.g1,
  12.     R.drawable.g2,
  13.     R.drawable.g3,
  14. };
  15.     ImageButton bt1,bt2;
  16. Random generator = new Random();
  17.  
  18. /** Called when the activity is first created. */
  19. @Override
  20. public void onCreate(Bundle savedInstanceState)
  21. {
  22.     super.onCreate(savedInstanceState);
  23.     setContentView(R.layout.game);
  24.  
  25.     bt1=(ImageButton) findViewById(R.id.bt1);
  26.     bt2=(ImageButton) findViewById(R.id.bt2);
  27.  
  28.     ArrayList<Object> lista = new ArrayList<>();
  29.     lista.add(imageid[generator.nextInt(imageid.length)]);
  30.     lista.add(imageidgr[generator.nextInt(imageidgr.length)]);
  31.  
  32.     Collections.shuffle(lista);
  33.  
  34.     bt1.setImageResource(lista.get(0));
  35.     bt2.setImageResource(lista.get(1));
  36.  
  37. }
  38.  
  39. public void v1 (View view){
  40.  
  41.     if (???){Toast toast = Toast.makeText(getApplicationContext(),
  42.                                  "Да!",
  43.                                  Toast.LENGTH_SHORT);
  44.     toast.setGravity(Gravity.CENTER, 0, 0);
  45.     toast.show();}
  46.     else if(???) {Toast toast = Toast.makeText(getApplicationContext(),
  47.                                        "Нет!",
  48.                                        Toast.LENGTH_SHORT);
  49.         toast.setGravity(Gravity.CENTER, 0, 0);
  50.         toast.show();}
  51. }
  52.    
  53. bt1.setTag(lista.get(0))
  54.    
  55. if (Arrays.asList(imageid).contains(bt1.getTag())) ...
RAW Paste Data
Top