title: Android: How to use extend ListActivity in extend Fragment
body: <p>How to get the ListActivity properly into fragment? I always get an error.</p>
  
  <p>I have this fragment:</p>
  
  <pre><code>public class Tools extends Fragment {
  
      public Tools(){}
      RelativeLayout view;
      @Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container,
                               Bundle savedInstanceState) {
  
          view = (RelativeLayout) inflater.inflate(R.layout.tools, container, false);
          getActivity().setTitle("Tools");
          return view;
      }
  }
  </code></pre>
  
  <p>and I want to use this Extend ListActivity in that fragment:</p>
  
  <pre><code>public class MainActivity extends ListActivity {
      private String URL_ITEMS = "http://192.168.1.88/asd/getFixture.php";
      private static final String TAG_FIXTURE = "fixture";
      private static final String TAG_MATCHID = "matchId";
      private static final String TAG_TEAMA = "teamA";
      private static final String TAG_TEAMB = "teamB";
      JSONArray matchFixture = null;
      ArrayList&lt;HashMap&lt;String, String&gt;&gt; matchFixtureList = new ArrayList&lt;HashMap&lt;String, String&gt;&gt;();
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
          // Call Async task to get the match fixture
          new GetFixture().execute();
      }
      private class GetFixture extends AsyncTask&lt;Void, Void, Void&gt; {
          @Override
          protected void onPreExecute() {
              super.onPreExecute();
          }
          @Override
          protected Void doInBackground(Void... arg) {
              ServiceHandler serviceClient = new ServiceHandler();
              Log.d("url: ", "&gt; " + URL_ITEMS);
              String json = serviceClient.makeServiceCall(URL_ITEMS,ServiceHandler.GET);
              // print the json response in the log
              Log.d("Get match fixture response: ", "&gt; " + json);
              if (json != null) {
                  try {
                      Log.d("try", "in the try");
                      JSONObject jsonObj = new JSONObject(json);
                      Log.d("jsonObject", "new json Object");
                      // Getting JSON Array node
                      matchFixture = jsonObj.getJSONArray(TAG_FIXTURE);
                      Log.d("json aray", "user point array");
                      int len = matchFixture.length();
                      Log.d("len", "get array length");
                      for (int i = 0; i &lt; matchFixture.length(); i++) {
                          JSONObject c = matchFixture.getJSONObject(i);
                          String matchId = c.getString(TAG_MATCHID);
                          Log.d("matchId", matchId);
                          String teamA = c.getString(TAG_TEAMA);
                          Log.d("teamA", teamA);
                          String teamB = c.getString(TAG_TEAMB);
                          Log.d("teamB", teamB);
                          //  hashmap for single match
                          HashMap&lt;String, String&gt; matchFixture = new HashMap&lt;String, String&gt;();
                          // adding each child node to HashMap key =&gt; value
                          matchFixture.put(TAG_MATCHID, matchId);
                          matchFixture.put(TAG_TEAMA, teamA);
                          matchFixture.put(TAG_TEAMB, teamB);
                          matchFixtureList.add(matchFixture);
                      }
                  }
                  catch (JSONException e) {
                      Log.d("catch", "in the catch");
                      e.printStackTrace();
                  }
              } else {
                  Log.e("JSON Data", "Didn't receive any data from server!");
              }
              return null;
          }
          @Override
          protected void onPostExecute(Void result) {
              super.onPostExecute(result);
              ListAdapter adapter = new SimpleAdapter(
                      MainActivity.this, matchFixtureList,
                      R.layout.list_item, new String[] {
                      TAG_MATCHID, TAG_TEAMA,TAG_TEAMB
              }
                      , new int[] {
                      R.id.matchId,R.id.teamA,
                      R.id.teamB
              }
              );
              setListAdapter(adapter);
          }
      }
  </code></pre>
  
  <p>This is the code by which I tried to put that ListActivity into Fragment:</p>
  
  <pre><code>public class terbaru extends Fragment {
  
      public terbaru(){}
      RelativeLayout view;
      private String URL_ITEMS = "http://192.168.1.88/asd/getFixture.php";
      private static final String TAG_FIXTURE = "fixture";
      private static final String TAG_MATCHID = "matchId";
      private static final String TAG_TEAMA = "teamA";
      private static final String TAG_TEAMB = "teamB";
      JSONArray matchFixture = null;
      ArrayList&lt;HashMap&lt;String, String&gt;&gt; matchFixtureList = new ArrayList&lt;HashMap&lt;String, String&gt;&gt;();
  
      @Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container,
                               Bundle savedInstanceState) {
  
          view = (RelativeLayout) inflater.inflate(R.layout.terbarus, container, false);
          // Call Async task to get the match fixture
          new GetFixture().execute();
      }
  
      private class GetFixture extends AsyncTask&lt;Void, Void, Void&gt; {
          @Override
          protected void onPreExecute() {
              super.onPreExecute();
          }
          @Override
          protected Void doInBackground(Void... arg) {
              ServiceHandler serviceClient = new ServiceHandler();
              Log.d("url: ", "&gt; " + URL_ITEMS);
              String json = serviceClient.makeServiceCall(URL_ITEMS,ServiceHandler.GET);
              // print the json response in the log
              Log.d("Get match fixture response: ", "&gt; " + json);
              if (json != null) {
                  try {
                      Log.d("try", "in the try");
                      JSONObject jsonObj = new JSONObject(json);
                      Log.d("jsonObject", "new json Object");
                      // Getting JSON Array node
                      matchFixture = jsonObj.getJSONArray(TAG_FIXTURE);
                      Log.d("json aray", "user point array");
                      int len = matchFixture.length();
                      Log.d("len", "get array length");
                      for (int i = 0; i &lt; matchFixture.length(); i++) {
                          JSONObject c = matchFixture.getJSONObject(i);
                          String matchId = c.getString(TAG_MATCHID);
                          Log.d("matchId", matchId);
                          String teamA = c.getString(TAG_TEAMA);
                          Log.d("teamA", teamA);
                          String teamB = c.getString(TAG_TEAMB);
                          Log.d("teamB", teamB);
                          //  hashmap for single match
                          HashMap&lt;String, String&gt; matchFixture = new HashMap&lt;String, String&gt;();
                          // adding each child node to HashMap key =&gt; value
                          matchFixture.put(TAG_MATCHID, matchId);
                          matchFixture.put(TAG_TEAMA, teamA);
                          matchFixture.put(TAG_TEAMB, teamB);
                          matchFixtureList.add(matchFixture);
                      }
                  }
                  catch (JSONException e) {
                      Log.d("catch", "in the catch");
                      e.printStackTrace();
                  }
              } else {
                  Log.e("JSON Data", "Didn't receive any data from server!");
              }
              return null;
          }
          @Override
          protected void onPostExecute(Void result) {
              super.onPostExecute(result);
              ListAdapter adapter = new SimpleAdapter(
                      terbaru.this, matchFixtureList,
                      R.layout.list_item, new String[] {
                      TAG_MATCHID, TAG_TEAMA,TAG_TEAMB
              }
                      , new int[] {
                      R.id.matchId,R.id.teamA,
                      R.id.teamB
              }
              );
              setListAdapter(adapter);
              return view;
          }
      }
  </code></pre>