title: NullPointerException on .setAdapter in a Fragment with ListView not work
body: <p>I work in Android App ListView working under a layer fragment by fragment, but I can not make it work. I got an error that says:</p>
  
  <blockquote>
    <p>setListAdapter method (ListAdapter) is undefined for new Runnable () {}</p>
  </blockquote>
  
  <p>I do not know what I need to change to get this working.</p>
  
  <pre><code>public class FragmentA extends Fragment {
  
      private String url = "http://192.168.2.150/54_tower/Json_Tower.php";
  
      private static final String J_NAME = "t_name";
      private static final String J_NUM = "t_num";
      private static final String J_FLOOR = "t_floor";
      private static final String J_CLASS = "t_room_class";
      private static final String J_TEACHER = "t_room_teacher";
      private static final String J_TOILET = "t_toilet";
      private static final String J_MAP = "t_map";
  
      private static final String D_NAME = "NAME";
      private static final String D_NUM = "NUM";
      private static final String D_FLOOR = "FLOOR";
      private static final String D_CLASS = "CLASS";
      private static final String D_TEACHER = "TEACHER";
      private static final String D_TOILET = "TOILET";
      private static final String D_MAP = "MAP";
  
      private static final String TAG_SUCCESS = "success";
      private static final String TAG_PRODUCTS = "products";
  
      Activity act;
      ListView ListView1;
  
      JSONArray products = null;
  
      private ProgressDialog pDialog;
  
      JSONParser jParser = new JSONParser();
  
      ArrayList&lt;HashMap&lt;String, String&gt;&gt; MyArrList;
  
      public static FragmentA newInstance(int page, String title) {
          FragmentA fragmentFirst = new FragmentA();
          Bundle args = new Bundle();
          args.putInt("someInt", page);
          args.putString("someTitle", title);
          fragmentFirst.setArguments(args);
          return fragmentFirst;
      }
  
      public View onCreateView(LayoutInflater inflater, ViewGroup container,
              Bundle savedInstanceState) {
          View rootView = inflater.inflate(R.layout.main_tower, container, false);
  
          // Permission StrictMode
          if (android.os.Build.VERSION.SDK_INT &gt; 9) {
              StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder()
                      .permitAll().build();
              StrictMode.setThreadPolicy(policy);
          }
  
          MyArrList = new ArrayList&lt;HashMap&lt;String, String&gt;&gt;();
  
          new LoadAllData().execute();
  
          final ListView lisView1 = (ListView) rootView
                  .findViewById(R.id.listView1);
  
          lisView1.setOnItemClickListener(new OnItemClickListener() {
  
              public void onItemClick(AdapterView&lt;?&gt; parent, View view,
                      int position, long id) {
  
                  Intent i = new Intent(getActivity(), Map.class);
                  startActivity(i);
  
              }
          });
  
          return rootView;
      }
  
      public void onActivityResult(int requestCode, int resultCode, Intent data) {
          super.onActivityResult(requestCode, resultCode, data);
          // if result code 100
          if (resultCode == 100) {
              // if result code 100 is received
              // means user edited/deleted product
              // reload this screen again
              // Intent intent = act.getIntent();
              // act.finish();
              // startActivity(intent);
          }
  
      }
  
      class LoadAllData extends AsyncTask&lt;String, String, String&gt; {
  
          protected void onPreExecute() {
              super.onPreExecute();
              pDialog = new ProgressDialog(getActivity());
              pDialog.setMessage("Loading Please wait...");
              pDialog.setIndeterminate(false);
              pDialog.setCancelable(false);
              pDialog.show();
          }
  
          protected String doInBackground(String... args) {
  
              List&lt;NameValuePair&gt; params = new ArrayList&lt;NameValuePair&gt;();
  
              JSONObject json = jParser.makeHttpRequest(url, "GET", params);
  
              Log.d("All JSon: ", json.toString());
  
              try {
                  int success = json.getInt(TAG_SUCCESS);
  
                  if (success == 1) {
                      products = json.getJSONArray(TAG_PRODUCTS);
  
                      HashMap&lt;String, String&gt; map = new HashMap&lt;String, String&gt;();
  
                      // Log.d("TAG JSON",""+data.toString());
  
                      for (int i = 0; i &lt; products.length(); i++) {
                          JSONObject c = products.getJSONObject(i);
  
                          // adding each child node to HashMap key =&gt; value
                          map = new HashMap&lt;String, String&gt;();
                          map.put(D_NAME, c.getString(J_NAME));
                          map.put(D_NUM, c.getString(J_NUM));
                          map.put(D_FLOOR, c.getString(J_FLOOR));
                          map.put(D_CLASS, c.getString(J_CLASS));
                          map.put(D_TEACHER, c.getString(J_TEACHER));
                          map.put(D_TOILET, c.getString(J_TOILET));
                          map.put(D_MAP, c.getString(J_MAP));
  
                          MyArrList.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;
          }
  
          protected void onPostExecute(String file_url) {
              pDialog.dismiss();
  
              final ArrayList&lt;HashMap&lt;String, String&gt;&gt; MyArrList = new ArrayList&lt;HashMap&lt;String, String&gt;&gt;();
              final ListView myList = (ListView) getView().findViewById(
                      R.id.listView1);
  
              act.runOnUiThread(new Runnable() {
                  public void run() {
                      ListAdapter sAdap = new SimpleAdapter(getActivity(),
                              MyArrList, R.layout.tower_column, new String[] {
                                      D_NAME, D_NUM, D_FLOOR, D_CLASS, D_TEACHER,
                                      D_TOILET, D_MAP }, new int[] { R.id.Name,
                                      R.id.Num, R.id.Floor, R.id.Room_Class,
                                      R.id.Room_Teacher, R.id.Toilet });
                      myList.setAdapter(sAdap);
                  }
              });
  
          }
  
      }
  }
  </code></pre>
  
  <p>Here is the LogCat: <a href="https://www.facebook.com/photo.php?fbid=1391126094516281&amp;l=bf3f9518a8" rel="nofollow">Image LogCat</a></p>