Guest User

Untitled

a guest
Jul 18th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.58 KB | None | 0 0
  1.         for (int i=0; i< ll_p4_l.getChildCount(); i++){
  2.             final int nr = i + 1;
  3.             Button b =  (Button) ll_p4_l.getChildAt(i);
  4.             b.setOnClickListener(new OnClickListener() {               
  5.                 public void onClick(View v) {
  6.                     doEvaluation(nr);
  7.                 }
  8.             });
  9.         }
  10. ------------------------------------------
  11.  
  12.  
  13.         Button[][][] bFieldPos = {    
  14. {       {b1_l1, b1_l2, b1_l3, b1_l4 },{b1_r1, b1_r2, b1_r3, b1_r4 }     },
  15. {       {b2_l1, b2_l2, b2_l3, b2_l4 },{b2_r1, b2_r2, b2_r3, b2_r4 }     },
  16. {       {b3_l1, b3_l2, b3_l3, b3_l4 },{b3_r1, b3_r2, b3_r3, b3_r4 }     },
  17. {       {b4_l1, b4_l2, b4_l3, b4_l4 },{b4_r1, b4_r2, b4_r3, b4_r4 }     },
  18. {       {b5_l1, b5_l2, b5_l3, b5_l4 },{b5_r1, b5_r2, b5_r3, b5_r4 }     },
  19. {       {b6_l1, b6_l2, b6_l3, b6_l4 },{b6_r1, b6_r2, b6_r3, b6_r4 }     },
  20. {       {bSt_l1, bSt_l2, bSt_l3, bSt_l4 },      {}                              },
  21. {       {bDia_l1, bDia_l2, bDia_l3, bDia_l4 },  {}                              }
  22.                                 };
  23.    
  24.    
  25.     LinearLayout ll_p1, ll_p2, ll_p3, ll_p4, ll_p5, ll_p6, ll_pSt, ll_pDia;
  26.     LinearLayout[] linearlayout_pos = { ll_p1, ll_p2, ll_p3, ll_p4, ll_p5, ll_p6, ll_pSt, ll_pDia   };
  27.    
  28.  
  29.     @Override
  30.     public void onCreate(Bundle savedInstanceState) {
  31.         super.onCreate(savedInstanceState);
  32.         setContentView(R.layout.ingame);
  33.        
  34.         linearlayout_pos[0] = (LinearLayout) findViewById(R.id.ll_p1);
  35.         linearlayout_pos[1] = (LinearLayout) findViewById(R.id.ll_p2);
  36.         linearlayout_pos[2] = (LinearLayout) findViewById(R.id.ll_p3);
  37.         linearlayout_pos[3] = (LinearLayout) findViewById(R.id.ll_p4);
  38.         linearlayout_pos[4] = (LinearLayout) findViewById(R.id.ll_p5);
  39.         linearlayout_pos[5] = (LinearLayout) findViewById(R.id.ll_p6);
  40.         linearlayout_pos[6] = (LinearLayout) findViewById(R.id.ll_pSt);
  41.         linearlayout_pos[7] = (LinearLayout) findViewById(R.id.ll_pDia);
  42.        
  43. for (int n=0; n<linearlayout_pos.length;n++){
  44.     for (int j=0; j < linearlayout_pos[n].getChildCount(); j++){
  45.         for (int i=0; i < ((ViewGroup)(linearlayout_pos[n].getChildAt(j))).getChildCount(); i++){
  46.                    
  47.                    
  48. bFieldPos[n][j][i] = (Button) findViewById(((ViewGroup)(linearlayout_pos[n].getChildAt(j))).getChildAt(i).getId());
  49.                        
  50. final int nr = i + 1;
  51. Button bFieldPos[n][j][i] =  (Button) ((ViewGroup)(linearlayout_pos[n].getChildAt(j))).getChildAt(i);
  52.                         bFieldPos[n][j][i].setOnClickListener(new OnClickListener()            
  53.  
  54.         {                          
  55.                     public void onClick(View v) {
  56.                           doEvaluation(nr);
  57.                     }
  58.                  });
  59.  
  60.  
  61.                 }
  62.     }
  63. }
  64.  
  65.    
  66. }
Add Comment
Please, Sign In to add comment