I'm android junior.

I'm trying to parse JSON URL into fragment and display it in Listview. I'm stuck for hours with various tutorials and each one is following different way. 

So, please this is what I have reached, let me know what should I do further to get it working! Appreciate your help - a lot of code is copy/paste from different tutorials, plus the JSON file is just applied in different tutorial, basic one I'm just trying to get it displayed.

activity\_main.xml

```
<android.support.v4.view.ViewPager xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/pager"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.example.sampleapp.MainActivity" />

```

fragment\_main.xml

```
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context="com.example.sampleapp.MainActivity$PlaceholderFragment" >

    <TextView
        android:id="@+id/section_label"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />

    <TextView
        android:id="@+id/text1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/section_label"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="171dp"
        android:text="Large Text"
        android:textAppearance="?android:attr/textAppearanceLarge" />

</RelativeLayout>

```

itune\_frag.xml

```
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:orientation="vertical" > 

     <TextView android:id="@+id/vehicleType" 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:text="vehicleType" /> 

     <TextView android:id="@+id/vehicleColor" 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:text="vehicleColor" /> 

</LinearLayout>

```

fav\_frag.xml

```
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin">

    <TextView
        android:id="@+id/text1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/section_label"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="171dp"
        android:text="Favvvvvv"
        android:textAppearance="?android:attr/textAppearanceLarge" />

</RelativeLayout>

```

MainActivity.java

```
package com.example.sampleapp;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import android.app.Activity;
import android.app.ActionBar;
import android.app.Fragment;
import android.app.FragmentManager;
import android.app.FragmentTransaction;
import android.content.Context;
import android.support.v13.app.FragmentPagerAdapter;
import android.os.Bundle;
import android.support.v4.view.ViewPager;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.ArrayAdapter;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.SimpleAdapter;

public class MainActivity extends Activity implements ActionBar.TabListener {

    SectionsPagerAdapter mSectionsPagerAdapter;
    ViewPager mViewPager;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        final ActionBar actionBar = getActionBar();
        actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

        mSectionsPagerAdapter = new SectionsPagerAdapter(getFragmentManager());

        mViewPager = (ViewPager) findViewById(R.id.pager);
        mViewPager.setAdapter(mSectionsPagerAdapter);

        mViewPager
                .setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
                    @Override
                    public void onPageSelected(int position) {
                        actionBar.setSelectedNavigationItem(position);
                    }
                });

        actionBar.addTab(actionBar.newTab().setText("iTunes List").setTabListener(this));
        actionBar.addTab(actionBar.newTab().setText("Favourite").setTabListener(this));

    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        int id = item.getItemId();
        if (id == R.id.action_settings) {
            return true;
        }
        return super.onOptionsItemSelected(item);
    }

    @Override
    public void onTabSelected(ActionBar.Tab tab,
            FragmentTransaction fragmentTransaction) {
        mViewPager.setCurrentItem(tab.getPosition());
    }

    @Override
    public void onTabUnselected(ActionBar.Tab tab,
            FragmentTransaction fragmentTransaction) {
    }

    @Override
    public void onTabReselected(ActionBar.Tab tab,
            FragmentTransaction fragmentTransaction) {
    }

    /**
     * A {@link FragmentPagerAdapter} that returns a fragment corresponding to
     * one of the sections/tabs/pages.
     */
    public class SectionsPagerAdapter extends FragmentPagerAdapter {

        public SectionsPagerAdapter(FragmentManager fm) {
            super(fm);
        }

        @Override
        public Fragment getItem(int position) {
            Fragment fragment = new Fragment();  
            switch (position) {  
            case 0:  
                return fragment = new iTuneFragment();  
            case 1:  
                return fragment = new favFragment();  
            default:  
                break;  
            }
            return fragment; 
        }

        @Override
        public int getCount() {
            return 2;
        }

        @Override
        public CharSequence getPageTitle(int position) {
            return null;
        }
    }

}

```

iTuneFragment.java

```
    class iTuneFragment extends Fragment {

    JSONArray user = null;
    ArrayList<HashMap<String, String>> jsonlist = new ArrayList<HashMap<String, String>>();

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        // Inflate the layout for this fragment

        iTuneList ll = new iTuneList();

        return inflater.inflate(R.layout.itune_frag, container, false);
    }

}

```

iTuneList.java

```
public final class iTuneList extends ListFragment {

    // URL to get JSON Array
    private static String url = "http://docs.blackberry.com/sampledata.json";

    // JSON Node Names
    private static final String VTYPE = "vehicleType";
    private static final String VCOLOR = "vehicleColor";

    JSONArray user = null;

    ArrayList<HashMap<String, String>> jsonlist = new ArrayList<HashMap<String, String>>();

    public iTuneList() {
    }

    @Override
    public void onActivityCreated(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onActivityCreated(savedInstanceState);
        new asy().execute();
    }

    private class asy extends
            AsyncTask<Void, Void, ArrayList<HashMap<String, String>>> {

        @Override
        protected ArrayList<HashMap<String, String>> doInBackground(
                Void... params) {
            // Creating new JSON Parser
            JSONParser jParser = new JSONParser();

            // Getting JSON from URL
            JSONArray json = jParser.getJSONFromUrl(url);
            for (int i = 0; i < json.length(); i++) {

                try {
                    JSONObject c = json.getJSONObject(i);

                    String vtype = c.getString(VTYPE);
                    String vcolor = c.getString(VCOLOR);
                    Log.e("iTuneList.java", "JSON: " + vtype);
                    HashMap<String, String> map = new HashMap<String, String>();

                    // Add child node to HashMap key & value
                    map.put(VTYPE, vtype);
                    map.put(VCOLOR, vcolor);
                    jsonlist.add(map);

                } catch (JSONException e) {
                    e.printStackTrace();
                }
            }
            return jsonlist;
        }

        @Override
        protected void onPostExecute(
                ArrayList<HashMap<String, String>> result) {
            // TODO Auto-generated method stub
            super.onPostExecute(result);
            ListAdapter adapter = new SimpleAdapter(getActivity(), result,
                    R.layout.itune_frag, new String[] { VTYPE, VCOLOR, },
                    new int[] { R.id.vehicleType, R.id.vehicleColor });
            setListAdapter(adapter);
        }

    }
}

```

Additionally, I have JSONParser.java which uses getJSONFromUrl - seems fine wrapper class. And also, favFragment.java which is different story, don't mind it for now, it works fine.

THAAAAAAAAAANKS!!