try {
answerField.setText("Unscrambling...This may take a minute");
BufferedInputStream(getAssets().open("wordlist.txt"));
BufferedInputStream[] textfile = new BufferedInputStream[28];
for(int i = 0; i<28; i++){
textfile[i] = new BufferedInputStream(getAssets().open(i+1+".txt"));
}
answerField.setText(Unscramble.go(tField.getText()+"", textfile));
My issue is with the line answerField.setText(“Unscrambling…This may take a minute”);
If the code is as-is, then this line will do nothing, but, if I take away the last line of the code answerField.setText(Unscramble.go(tField.getText()+””, textfile)); it works find and the TextView says “Unscrambling…this may take a minute”
The goal is for it to have that message until the program is done unscrambling, then it will have the results.
Any help would be really greatly appreciated, as I have no clue what I am doing or why this is happening.
The problem is that the UI does not update between the first call to
setTextand the second. One solution, as @AVD mentioned, is to useToast.The other solution, which I believe is recommended, is to use
AsyncTask. The idea here would be to set your text to the “Unscrambling” message inonPreExecute, then run your main task indoInBackground, then finally set the text to theUnscramble.*string inonPostExecute.The documentation link I provided above has a great
AsyncTaskcode there, which can be manipulated to handle just about anything.