title: populating listview through a fragment
body: <p>I have a class extending listFragment. I have written code for fetching json response in a method which is called in oncreate of the class. For fetching json in background I have created new inner class which extends asyncTask. I can get the jsonarrays and strings in the json response in the logcat. But when I try to save them in a string array and pass them my custom baseadapter, I get a nullpointer exception.</p>
  
  <pre><code>    public class OnlineInfo extends ListFragment {
  
  public static String result;
  public String[] Technologies1;
  public String[] TechnologyDescription1;
  
  @Override
  public void onListItemClick(ListView l, View v, int position, long id) {
      // TODO Auto-generated method stub
      super.onListItemClick(l, v, position, id);
  }
  
  @Override
  public void onCreate(Bundle savedInstanceState) {
      // TODO Auto-generated method stub
      super.onCreate(savedInstanceState);
       downloadjsonresponse();
  
  
  
  }
  
   public class Download extends AsyncTask&lt;String, Void, String&gt;
      {
  
  
          @Override
          protected String doInBackground(String... params) {
              // TODO Auto-generated method stub
              StringBuilder stringbuilder = new StringBuilder();
              HttpClient client = new DefaultHttpClient();
              HttpGet url = new HttpGet(params[0]);
              try
              {
                  Log.d("in background", "in background");
                  HttpResponse response = client.execute(url);
                  HttpEntity entity = response.getEntity();
                  InputStream stream = entity.getContent();
                  BufferedReader reader = new BufferedReader(new InputStreamReader(stream));
                  String line ;
                  while((line = reader.readLine()) != null)
                  {
                      stringbuilder.append(line);
                  }
              }
  
              catch(ClientProtocolException e)
              {
                  Log.d("error in clientprotocol", "error");
                  e.printStackTrace();
              }
              catch(IOException e)
              {
                  Log.d("error in IO", "error");
                  e.printStackTrace();
              }
              return stringbuilder.toString();
  
  
          }
  
          @Override
          protected void onPostExecute(String result) {
              // TODO Auto-generated method stub
  
              OnlineInfo.result = result;
              try {
                  JSONObject jsonobject = new JSONObject(result);
                  JSONArray raja = jsonobject.getJSONArray("Technologies");
                  //String raja = jsonobject.getJSONArray("Technologies").getJSONObject(0).getString("desc");
                  //Log.d("desc:", raja);
                  for(int i=0; i&lt;raja.length();i++)
                  {
  
                      Technologies1[i] = raja.getJSONObject(i).getString("name");
                      TechnologyDescription1[i] = raja.getJSONObject(i).getString("desc");
                      Log.d("technology :", raja.getJSONObject(i).getString("name"));
                      Log.d("technologydescription :", raja.getJSONObject(i).getString("desc"));
                  }
  
              } catch (JSONException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
                  Log.d("desc:", "error");
              }
              getListView().setAdapter(new AdapterForOnlineInfo(getActivity(), OnlineInfo.this.Technologies1, OnlineInfo.this.TechnologyDescription1));
  
  
          }
  
          }
  
   public void downloadjsonresponse()
      {
          Download jsonresponse = new Download();
          jsonresponse.execute("http://www.avantajsoftwares.com/result.json");
  
      }
  }
  </code></pre>
  
  <p>I could get the results in logcat whenever I comment these two lines in for-loop:</p>
  
  <pre><code>    Technologies1[i] = raja.getJSONObject(i).getString("name");
  TechnologyDescription1[i] = raja.getJSONObject(i).getString("desc");
  </code></pre>
  
  <p>Don't know what's going wrong. Please somebody provide me some insight....:-(</p>