title: MainActivity.this is not an enclosing class AsyncTask
body: <p>I'm trying to create an AsyncTask for the 1st time, but I don't have much luck.</p>
  
  <p>My AsyncTask needs to get some information from a server and then add new layouts to the main layout to display this information.</p>
  
  <p>Everything seems to be more or less clear but, the error message "MainActivity is not an enclosing class" is bothering me.</p>
  
  <p>Nobody else seems to have this problem, so I think I miss something very obvious, I just don't know what it is.</p>
  
  <p>Also, I'm not sure if I used the right way to get the context, and because my application doesn't compile so I can't test it.</p>
  
  <p>Your help is much appreciated.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>public class BackgroundWorker extends AsyncTask&lt;Context, String, ArrayList&lt;Card&gt;&gt; {
      Context ApplicationContext;
  
      @Override
      protected ArrayList&lt;Card&gt; doInBackground(Context... contexts) {
          this.ApplicationContext = contexts[0];//Is it this right way to get the context?
          SomeClass someClass = new SomeClass();
  
          return someClass.getCards();
      }
  
      /**
       * Updates the GUI before the operation started
       */
      @Override
      protected void onPreExecute() {
          super.onPreExecute();
      }
  
      @Override
      /**
       * Updates the GUI after operation has been completed
       */
      protected void onPostExecute(ArrayList&lt;Card&gt; cards) {
          super.onPostExecute(cards);
  
          int counter = 0;
          // Amount of "cards" can be different each time
          for (Card card : cards) {
              //Create new view
              LayoutInflater inflater = (LayoutInflater) ApplicationContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
              ViewSwitcher view = (ViewSwitcher)inflater.inflate(R.layout.card_layout, null);
              ImageButton imageButton = (ImageButton)view.findViewById(R.id.card_button_edit_nickname);
  
              /**
               * A lot of irrelevant operations here
               */ 
  
              // I'm getting the error message below
              LinearLayout insertPoint = (LinearLayout)MainActivity.this.findViewById(R.id.main);
              insertPoint.addView(view, counter++, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
          }
      }
  }
  </code></pre>