title: problems with ProgressDialog,RunOnUiThread and ListAdapter
body: <p>Ok i've written this android program that has 3 tabs(MEALS,DRINKS AND DESSERT) each in its own activity with a fragment.The problem i'm having now is with retrieving the list from a mysql database and displaying this list in each tab.I'de already ran and executed a custom code which displays a list of items retrieved from a mysql database in a single list,which worked fine.Now bringing this code to my program gives me 3 errors<br>
  1)</p>
  
  <pre><code>pDialog = new ProgressDialog(MealsFragment.this); which says        
  ProgressDialog(android.context,Context) in progressDialog cannot be applied to          
  com.example.tab.tablayout.MealsFragment
  </code></pre>
  
  <p>2)
      runOnUiThread(new Runnable() which says "cannot resolve method runonuithread "</p>
  
  <p>3)is all about the list adapter.</p>
  
  <p>The initial code used OnCreate,but my fragment uses oncreateView.I dont know if thats the issue.</p>
  
  <p>Here is the code for the MealsFragment.java </p>
  
  <pre><code>package com.example.tabs.tablayout;
  
  import java.util.ArrayList;
  import java.util.HashMap;
  import java.util.List;
  
  import org.apache.http.NameValuePair;
  import org.json.JSONArray;
  import org.json.JSONException;
  import org.json.JSONObject;
  
  import android.app.ListActivity;
  import android.app.ProgressDialog;
  import android.content.Intent;
  import android.os.AsyncTask;
  import android.os.Bundle;
  import android.support.v4.app.ListFragment;
  import android.util.Log;
  import android.view.LayoutInflater;
  import android.view.View;
  import android.view.ViewGroup;
  import android.widget.AdapterView;
  import android.widget.AdapterView.OnItemClickListener;
  import android.widget.ListAdapter;
  import android.widget.ListView;
  import android.widget.SimpleAdapter;
  import android.widget.TextView;
  
  /**
   * Created by GIGABYTE on 5/21/2014.
   */
  public class MealsFragment extends ListFragment {
  
      // Progress Dialog
      private ProgressDialog pDialog;
  
      // Creating JSON Parser object
      JSONParser jParser = new JSONParser();
  
      ArrayList&lt;HashMap&lt;String, String&gt;&gt; mealsList;
  
      // url to get all products list
      private static String url_all_meals = "http://10.180.79.73/dbase_connect/get_all_meals.php";
  
      // JSON Node names
      private static final String TAG_SUCCESS = "success";
      private static final String TAG_MEALS = "meals";
      private static final String TAG_MID = "mid";
      private static final String TAG_NAME = "name";
  
      // products JSONArray
      JSONArray meals = null;
  
      @Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container,
                               Bundle savedInstanceState) {
  
          View rootView = inflater.inflate(R.layout.fragment_meals, container, false);
  
  
  
          // Hashmap for ListView
          mealsList = new ArrayList&lt;HashMap&lt;String, String&gt;&gt;();
  
          // Loading meals in Background Thread
          new LoadAllMeals().execute();
  
  
          // Get listview
          ListView lv = getListView();
  
          return rootView;
      }
  
  
      /**
           * Background Async Task to Load all product by making HTTP Request
           * */
         class LoadAllMeals extends AsyncTask&lt;String, String, String&gt; {
  
              /**
               * Before starting background thread Show Progress Dialog
               * */
  
              protected void onPreExecute() {
                  super.onPreExecute();
                  pDialog = new ProgressDialog(MealsFragment.this);
                  pDialog.setMessage("Loading Meals. Please wait...");
                  pDialog.setIndeterminate(false);
                  pDialog.setCancelable(false);
                  pDialog.show();
              }
  
              /**
               * getting All Meals from url
               * */
              protected String doInBackground(String... args) {
                  // Building Parameters
                  List&lt;NameValuePair&gt; params = new ArrayList&lt;NameValuePair&gt;();
                  // getting JSON string from URL
                  JSONObject json = jParser.makeHttpRequest(url_all_meals, "GET", params);
  
                  // Check your log cat for JSON response
                  Log.d("All Meals: ", json.toString());
  
                  try {
                      // Checking for SUCCESS TAG
                      int success = json.getInt(TAG_SUCCESS);
  
                      if (success == 1) {
                          // Meals found
                          // Getting Array of Meals
                          meals = json.getJSONArray(TAG_MEALS);
  
                          // looping through All meals
                          for (int i = 0; i &lt; meals.length(); i++) {
                              JSONObject c = meals.getJSONObject(i);
  
                              // Storing each json item in variable
                              String id = c.getString(TAG_MID);
                              String name = c.getString(TAG_NAME);
  
                              // creating new HashMap
                              HashMap&lt;String, String&gt; map = new HashMap&lt;String, String&gt;();
  
                              // adding each child node to HashMap key =&gt; value
                              map.put(TAG_MID, id);
                              map.put(TAG_NAME, name);
  
                              // adding HashList to ArrayList
                              mealsList.add(map);
                          }
                      } /*else {
                          // no products found
                          // Launch Add New product Activity
                          Intent i = new Intent(getApplicationContext(),
                                  NewProductActivity.class);
                          // Closing all previous activities
                          i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                          startActivity(i);
                      }
                      */
                  } catch (JSONException e) {
                      e.printStackTrace();
                  }
  
                  return null;
              }
  
              /**
               * After completing background task Dismiss the progress dialog
               * **/
              protected void onPostExecute(String file_url) {
                  // dismiss the dialog after getting all meals
                  pDialog.dismiss();
                  // updating UI from Background Thread
                  runOnUiThread(new Runnable() {
                      public void run() {
                          /**
                           * Updating parsed JSON data into ListView
                           * */
                          ListAdapter adapter = new SimpleAdapter(
                                  MealsFragment.this, mealsList,
                                  R.layout.meals_list_item, new String[] {TAG_MID,
                                  TAG_NAME},
                                  new int[] { R.id.mid, R.id.name });
                          // updating listview
                          setListAdapter(adapter);
  
  
                      }
                  });
  
              }
  
  
  }
  }
  </code></pre>