Большое чтение TXT-файлов через кнопки ожидания - PullRequest
0 голосов
/ 23 апреля 2020

Привет, почему этот код работает "onCreate", но не работает в кнопке

Действительно, я использую не более 20 МБ, но для тестирования я вставил 90 МБ

   public class MainActivity extends AppCompatActivity {
   TextView textView;    DataInputStream textFileStream = null;
   public void readbigtext(){          
       try {
           textFileStream = new DataInputStream(getAssets().open(String.format("test1.txt")));
        } catch (IOException e) {e.printStackTrace();}
        Scanner sc = new Scanner(textFileStream);
        while (sc.hasNextLine()) {textView.append(sc.nextLine());}
    }
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Button bigbutton = (Button) findViewById(R.id.bigbutton);
        textView = (TextView) findViewById(R.id.bigfile);
        textView.append("test begin");
        //90Mb here IS WORKING!           
        // readbigtext();
        bigbutton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //90Mb here DON`T WORKING
                readbigtext();
                }
        });
    }
    }
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...