0

我正在尝试在List<String>内部启动AsyncTask并且不再调用整个任务,但没有错误。

需要明确的是,我追求的唯一原因List是它让我有机会使用sublist.

如果有简单的方法或者您发现了错误,请分享。

protected void updateTask()
{
     runOnUiThread(new Runnable() 
     {
         public void run() 
         {
                PatternTask myTask = new PatternTask();
                myTask.execute();
         }
     });
}
private class PatternTask extends AsyncTask<String, Void, String> {

    int eyes_closed;
    int eyes_opened;
    int eyes_avarage;

    String response = "NO DATA";
    protected String doInBackground(String... patterns) {
          String[] looper = getPattern().split("\n");
          List<String> patternList = new ArrayList<String>();
          for (int i = 0; i < looper.length; i++)
          {
             patternList.add(looper[i]); 
          }

          if (patternList.size() > 1200)
          {
                patternList.subList(0, patternList.size() - 1200).clear();
                ...
                ... 
          }
          else
                return response;
        }

        @Override
        protected void onPostExecute(String result) {
            Toast.makeText(FdActivity.this, result, Toast.LENGTH_LONG).show();          
        }       
}   
4

0 回答 0