title: How to fill ListView with Adapters
body: <p>I'm aware that this is very simple question but I'm a newbie in Android development so please go easy on me.<br>
  Problem that I have is in one of the fragments (AsyncTask specifically) that lays in my main activity.
  AsyncTask sends out data to php script which then returns according data in json format. This is then processed and saved to <code>jsonlist</code> array. Up until post execute everything works fine data is downloaded, processed etc. However when program reaches post execute problems start to pop out. And basically i'm unable to list out all the data from <code>jsonlist</code> to listview </p>
  
  <pre><code>    //setting up an array
      ArrayList&lt;HashMap&lt;String, String&gt;&gt; jsonlist = new ArrayList&lt;HashMap&lt;String, String&gt;&gt;();
      //creating list view variable
      ListView listview;
      //Define work in progress dialog
      private ProgressDialog mProgressDialog;  
  
  private class ProgressTask extends AsyncTask&lt;String, Void, Boolean&gt; {
          @Override
          protected void onPreExecute() {
              super.onPreExecute();
  
              // Create a progressdialog
              mProgressDialog = new ProgressDialog(getActivity());
  
              // Set progressdialog title
              mProgressDialog.setTitle("Please wait");
  
              // Set progressdialog message
              mProgressDialog.setMessage("Fetching data...");
              mProgressDialog.setIndeterminate(false);
  
          }
  
          @Override
          protected Boolean doInBackground(String... params) {
              //To do in the background
              //Define variable of JSON parser type
              JSONParser jParser = new JSONParser();
  
              //Pass url to json parser class to fetch and save it into array variable
              JSONArray json = jParser.getJSONFromUrl(url);
  
              //loop from 0 to length of an array by increasing by 1
              for (int i = 0; i &lt; json.length(); i++) {
  
                  //Try and catch routine to prevent any crashes
                  try {
                      //Get an object defined in { ... } in original json file
                      JSONObject c = json.getJSONObject(i);
  
                      //Separate object by obtaining values for each of the sections
                      String vtitle = c.getString(title);
                      String vcontent = c.getString(content);
                      String vuser = c.getString(user);
  
                      HashMap&lt;String, String&gt; map = new HashMap&lt;String, String&gt;();
  
                      //Fill up an array with data extracted
                      map.put(title, vtitle);
                      map.put(content, vcontent);
                      map.put(user, vuser);
  
                      //Add values into jsonlist
                      jsonlist.add(map);
  
                  } catch (JSONException e)
                  {
                      //In case of any error Stack trace will be returned
                      e.printStackTrace();
                  }
              }
              //Once everything has been done return null value
              return null;
          }
          @Override
          protected void onPostExecute(Boolean aBoolean) {
              //Insert all data downloaded through list adapter
              ListAdapter adapter = new SimpleAdapter(getActivity(), jsonlist, R.layout.list_activity, new String[] { title, content, user }, new int[] { R.id.title, R.id.content, R.id.user });
  
              // Locate the listview 
              //listview = (ListView) findViewById(R.id.list);
  
              // Set the adapter to the ListView
              //listview.setAdapter(adapter);
  
              //Get rid off dialog when operation of fetching data has been done
              if (mProgressDialog.isShowing()) {
                  mProgressDialog.dismiss();
              }
          }
      }
  </code></pre>
  
  <p>As you can see i have tried the commented code but <code>listview = (ListView) findViewById(R.id.list);</code> returns following error:  </p>
  
  <blockquote>
    <p>Cannot resolve method findViewById(int)</p>
  </blockquote>
  
  <p>which prevents me from executing program. This is very upsetting because I literally have all the data i need in an array but only one line of code stops me from displaying it. </p>
  
  <p>I have also tried: </p>
  
  <pre><code>    ListAdapter adapter = new SimpleAdapter(context, jsonlist, R.layout.list_activity, new String[] { title, content, user }, new int[] { R.id.title, R.id.content, R.id.user });
      setListAdapter(adapter);
      lv = getListView();
  </code></pre>
  
  <p>But as in previous case error of unresolved method is returned. Which is due to the fact that fragment is extended by fragment and adding anything to it crashes it</p>
  
  <pre><code>public class Fragment2 extends Fragment, ListActivity {...}
  </code></pre>