public void create() { int width = display.getWidth(); int height = display.getHeight(); board = (GridLayout) activity.findViewById(com.example.wertalp.battleship.R.id.board); board.removeAllViews(); Button buttonSet = (Button) activity.findViewById(com.example.wertalp.battleship.R.id.button23); EditText edit1 = (EditText) activity.findViewById(com.example.wertalp.battleship.R.id.editText); // board.setColumnCount(Integer.parseInt(edit1.getText().toString())); // board.setRowCount(Integer.parseInt(edit1.getText().toString())); board.setColumnCount(10); board.setRowCount(10); laenge = (int) (this.getWidth() - 300) / board.getColumnCount(); breite = laenge; for (int i = 0; i <= board.getRowCount() - 1; i++) { for (int j = 0; j <= board.getColumnCount() - 1; j++) { CellButton button = new CellButton(activity); button.setBackgroundResource(com.example.wertalp.battleship.R.drawable.rectangle); button.setId(i + j); button.setyField(j); button.setxField(i); // button.setText(""+i+j); button.setLayoutParams(new LinearLayout.LayoutParams(laenge, breite)); board.addView(button); // anz++; if (i == 0) { button.setText("" + j); button.setBackgroundResource(com.example.wertalp.battleship.R.drawable.rectangle_second); } if (j == 0) { button.setText("" + i); button.setBackgroundResource(com.example.wertalp.battleship.R.drawable.rectangle_second); } if ((i != 0) && (j != 0)) { // button.setOnClickListener(new View.OnClickListener() { // @Override // public void onClick(View v) { // CellButton b = (CellButton) v; // Toast.makeText(getActivity().getBaseContext(), "" + b.getPositionText(), // Toast.LENGTH_SHORT).show(); // b.setBackgroundResource(com.example.wertalp.battleship.R.drawable.cross); // Butty = b; // Ship cur_Ship = new Ship(board); // show_popup(b); // } // }) ; } ; } } // create Methode ende } // End Create