private void addView(String text) { ThumbnailTextDeletableItemView view = new ThumbnailTextDeletableItemView( getBaseContext(), llPlayers.getChildCount(), getResources().getDrawable(R.drawable.golfer), text, getResources().getDrawable(R.drawable.delete)); view.setOnThumbnailTextDeletableItemDeleteClickListener(this); llPlayers.addView(view); }
@Override public void onClick(View v) { if (v == btnAddPlayer) { if (!etName.getText().toString().trim().equals("")) { addView(etName.getText().toString().trim()); etName.setText(""); btnAddPlayer.setEnabled(false); } } else if (v == btnStartGame) { int gameId = GameData.add(new Date(), getIntent().getIntExtra("course_id", -1)); PlayerData.add("Me", gameId); for (int i = 1; i < llPlayers.getChildCount(); i++) { ThumbnailTextDeletableItemView view = (ThumbnailTextDeletableItemView) llPlayers.getChildAt(i); PlayerData.add(view.getText(), gameId); } Intent i = new Intent(getApplicationContext(), GameActivity.class); i.putExtra("game_id", gameId); startActivity(i); } }