@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getWindow() .getDecorView() .setSystemUiVisibility(View.SYSTEM_UI_FLAG_FULLSCREEN); // hide status bar memoryGameScreen = new MemoryGameScreen(this); setContentView(memoryGameScreen); DisplayMetrics displaymetrics = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(displaymetrics); screenWidth = displaymetrics.widthPixels; screenHeight = displaymetrics.heightPixels; pauseBt = new PauseMenuButton(screenWidth, this); // ------------------ Code in order to hide the navigation bar -------------------- // menu.hideNavBar(this.getWindow()); // Start help screen Intent itn = new Intent(getApplicationContext(), HelpDialogActivity.class); itn.putExtra("appNum", 9); startActivity(itn); // Change and store the question Mode QrCodeScanner.questionMode = true; QrCodeScanner.storeQuestionMode(true); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); random = new Random(System.currentTimeMillis()); // populate words array from the available words in string.xml from list words String[] words = getResources().getStringArray(R.array.words); // pick a random word and convert it in char array randomNum = random.nextInt(words.length); choosenWord = words[randomNum]; wordArray = choosenWord.toCharArray(); // calculate the length of the choosen word numberOfLetters = choosenWord.length(); // initialize found letters with "_" and create an array with equal views lettersFound = new char[numberOfLetters]; for (int j = 0; j < numberOfLetters; j++) { lettersFound[j] = '_'; } lettersView = new View[numberOfLetters]; // initialize mistakes and correct letters to zero mistakes = 0; correctLetters = 0; // Dynamicaly create as many views as the letters of the word with the use of inflater setContentView(R.layout.activity_hangman_fixed); LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); TableRow letterTableRow = (TableRow) findViewById(R.id.letterTableRow0); for (int letters = 0; letters < numberOfLetters; letters++) { TextView newTextView = (TextView) inflater.inflate(R.layout.hangman_textview, null); newTextView.setText(R.string.underscore); newTextView.setTextColor(getResources().getColor(R.color.gold)); letterTableRow.addView(newTextView); lettersView[letters] = newTextView; lettersView[letters].setId(letters); // set id in order to use the same view later // because it is dynamicly created we can set as id only a number - here the id is // the counter of the for loop } // Has to be after the setContentView, otherway it crashes currentArch = (ImageView) findViewById(R.id.archImageView); // get the image view instance currentArch.setImageResource( R.drawable.hangman_wrong_0); // initialize the image to the first with no mistakes buttonListeners(); // apply button listeners for letter buttons // ------------------ Code in order to hide the navigation bar -------------------- // menu.hideNavBar(this.getWindow()); // Start help screen Intent itn = new Intent(getApplicationContext(), HelpDialogActivity.class); itn.putExtra("appNum", 11); startActivity(itn); // Change and store the question Mode QrCodeScanner.questionMode = true; QrCodeScanner.storeQuestionMode(true); }