Calling a fragment from another list type ListFragment

Hello everyone wanted to know if I can support, I have a project in which I have implemented a tablayout with 3 tabs, each tabs I have assigned a fragment, for the first tab I have a listfragment and show the list correctly, but selecting an element of the list want the switch to another fragment that will also display another list.

For example I have a list of categories, in the fragment of listfragment type in the first tab, but selecting an item from the list I want to show the items child of that category in another list, but in the same tab, reached the code, as managing that change, ie another fragment listfragment call type from listfragment.

File: TabCategoriasFragment.java
Code:

package com.gydsoluciones.grva.recetasperu;

import android.app.ProgressDialog;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.ListFragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.Toast;

import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.android.volley.VolleyLog;
import com.android.volley.toolbox.JsonArrayRequest;

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

/**
 * Created by grva on 20/05/2016.
 */
public class TabCategoriasFragment extends ListFragment{

    String[] categorias = {"Licores","Sopas","Pescados y Mariscos","Arroces","Ensaladas","Repostería","Salsas"};
    Integer[] pics = {R.drawable.licores,R.drawable.sopas,R.drawable.pescadosmariscos,R.drawable.arroces,R.drawable.ensaladas,R.drawable.reposteria,R.drawable.salsas};
    String[] descripcion = {
            "Los mejores licores","Selección de las mejores sopas y caldos",
            "Los mejores platos a base de pescados y mariscos","Arroz con pollo, Arroz chaufa, entre otros",
            "Las mejores ensaladas frescas","Lo mejor para endulzar el momento","Las mejores salsas basadas en la variedad peruana"
    };

    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        CategriaListAdapter adapter = new CategriaListAdapter(getActivity(),categorias,pics,descripcion);
        setListAdapter(adapter);
        return inflater.inflate(R.layout.lista_categorias,container,false);
    }

    @Override
    public void onListItemClick(ListView l, View v, int position, long id) {
        super.onListItemClick(l, v, position, id);
        String itemText = categorias[+position];

        String url = "url web service";
        ProgressDialog pDialog = new ProgressDialog(getContext());
        pDialog.setMessage("Cargando...");
        pDialog.show();

        final JsonArrayRequest req = new JsonArrayRequest(url, new Response.Listener<JSONArray>() {
            @Override
            public void onResponse(JSONArray response) {
                Log.d("json_array_req",response.toString());
                try {
                    String[] recetas = new String[response.length()];
                    for (int i = 0; i < response.length(); i++) {
                        JSONObject receta = (JSONObject) response.get(i);
                        recetas[i] = receta.getString("titurece");
                    }
                }catch(JSONException e)
                {
                    Log.d("json_array_req", e.toString());
                }
            }
        },new Response.ErrorListener(){
            @Override
            public void onErrorResponse(VolleyError error){
                VolleyLog.d("json_array_req","Error:" + error.getMessage());
            }
        });
        AppController.getInstance().addToRequestQueue(req,"json_array_req");
        pDialog.hide();
    }
}



from xda-developers http://ift.tt/1W8FjRm
via IFTTT