I am creating a Word-Game-Like application. I had an idea of making an arraylist on strings.xml for the Words and Questions. How would i check(in .java file) if the entered word is in the array list?
And then if the word is in there, it will show that it is correct. (Guess i have to use Toast if im not mistaken)
UPDATE: I now have an array.xml, and here's my current class file
ArrayAct.java
public class ArrayAct extends Activity{
Button mButton;
EditText mEdit;
String [] mArray;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.arrayact);
mArray = getResources().getStringArray(R.array.NameArrays);
final Button doneBtn = (Button)findViewById(R.id.doneBtn);
final EditText text = (EditText)findViewById(R.id.txtFld);
doneBtn.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
if (mArray.equals(text.getText().toString()))
Toast.makeText(getApplicationContext(), "Correct!", Toast.LENGTH_SHORT).show();
else
Toast.makeText(getApplicationContext(), "Incorrect.Please try again.", Toast.LENGTH_SHORT).show();
}
});
....
The result always show incorrect even if i input a word that is the same in the array. What might i be doing wrong in this case?