I am trying to set a large text in an EditText, the operation may take more than 30 seconds, so I use ProgressDialog. It appears, but no animation, and then disappears when the operation is performed. Here is my simplified code:
class FileOpener extends AsyncTask<File, Integer, String> { private ProgressDialog progress; @Override protected void onPreExecute() { progress = new ProgressDialog(context); ... progress.show(); } @Override protected StringBuilder doInBackground(File... files) { return readFile(); } @Override protected void onPostExecute(String content) { EditText editText = ... editText.post(new Runnable() { @Override public void run() { editText.setText(content); progress.dismiss(); } }); } }
What can I do to animate the execution dialog when setting up the text?
I also tried using this in onPostExecute
, the same thing, there is a dialogue, but there is no animation ...
EditText editText = ... new Thread() { @Override public void run() { editor.setText(content); progress.dismiss(); } }.start();
EDIT . This is not a question of the speed of my editing, which is terrible, as I understand it. This question is here . No matter how I improve the speed, installing the text will ALWAYS take a few seconds with large files, even with editing applications. Actually, this question is how to save the animation of the download dialog, since it is not currently animating when setting text in EditText. I donβt know anything, nothing can be changed in the user interface, if not in the user interface thread, then how can I update / revive the download? If this is not possible or just too complicated or hacked, then how can I show any type of loading animation when setting up the text.
source share