private void initSpell() { spell = SpellSet.getSpellSet().getSpell(spellNum); TextView word = (TextView) view.findViewById(R.id.word); final TextView belowTextView = (TextView) view.findViewById(R.id.below_text_view); final TextView spellOutput = (TextView) view.findViewById(R.id.spell_output); final EditText spellText = (EditText) view.findViewById(R.id.spell_text); Button submitButton = (Button) view.findViewById(R.id.spell_button); word.setText(spell.getWord()); submitButton.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { final String input = spellText.getText().toString(); if (input.equalsIgnoreCase(spell.getWord())) { spellText.setText(""); belowTextView.setText(R.string.yay); spellOutput.setText(R.string.correct); spellOutput.setVisibility(View.VISIBLE); } else if (input.equals("")) { spellText.setText(""); belowTextView.setText(R.string.error_below); spellOutput.setText(R.string.spell_blank_error); spellOutput.setVisibility(View.VISIBLE); } else { spellText.setText(""); belowTextView.setText(R.string.not_spell_answer); spellOutput.setText(R.string.incorrect); spellOutput.setVisibility(View.VISIBLE); } } }); }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); String diff = getActivity().getIntent().getStringExtra(Integer.toString(R.string.diff_key)); spellSet = new SpellSet(diff); spells = spellSet.getSpells(); }