Skip to main content
formatação e adição de tag de linguagem
Fonte Link

Iniciar classe Fragment de outra Classe Fragment (Android)

//Imports

Tenho uma classe GuiaDaCidade extends Fragments.

public class GuiaDaCidade extends Fragment {GuiaDaCidade.

public class GuiaDaCidade extends Fragment {

    View rootView;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        rootView = inflater.inflate(R.layout.guia_da_cidade, null);

        View botaoPasseios = (View) rootView.findViewById(R.id.btpasseios);
        View botaoAgenda = (View) rootView.findViewById(R.id.btagenda);

        botaoPasseios.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                startActivity(new Intent(getActivity(),Passeios.class));    ///O que fazer aqui?
            }
        });

        botaoAgenda.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {

                Uri uri = Uri.parse("http://www.agendanatal.com.br");
                Intent intent = new Intent(Intent.ACTION_VIEW, uri);
                startActivity(intent);

            }
        });

        return rootView;
    }

TenhoE a Classe Passeios extends fragments

public class Passeios extends Fragment {Passeios:

public class Passeios extends Fragment {

    private ArrayList<HashMap<String, String>> list;
    private ExpandableListAdapter listAdapter;
    private ExpandableListView expListView;
    private List<String> listDataHeader;
    private HashMap<String, List<String>> listDataChild;
    private WebView webView;
    private View rootView;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        rootView = inflater.inflate(R.layout.guia_passeios, null);

        expListView = (ExpandableListView) rootView.findViewById(R.id.listaexp);

        prepareListData();

        listAdapter = new ExpandableListAdapter(getActivity(), listDataHeader, listDataChild);

        expListView.setAdapter(listAdapter);
        expandeAll();
        expListView.setOnChildClickListener(new ExpandableListView.OnChildClickListener() {

            @Override
            public boolean onChildClick(ExpandableListView parent, View v,
                                        int groupPosition, int childPosition, long id) {

                mudaTela(groupPosition, childPosition);

                return false;
            }
        });

        return rootView;
    }

Como faco para iniciar a classe PasseiosPasseios a partir da classe GuiaDaCidadeGuiaDaCidade? no No metodo onclickListeneronclickListener da classe GuiaDaCidadeGuiaDaCidade ja tem +/- a ideia teoricateórica do que quero, porem naonão funciona.

Iniciar classe Fragment de outra Classe Fragment (Android)

//Imports

Tenho uma classe GuiaDaCidade extends Fragments.

public class GuiaDaCidade extends Fragment {

View rootView;

@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    rootView = inflater.inflate(R.layout.guia_da_cidade, null);

    View botaoPasseios = (View) rootView.findViewById(R.id.btpasseios);
    View botaoAgenda = (View) rootView.findViewById(R.id.btagenda);

    botaoPasseios.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            startActivity(new Intent(getActivity(),Passeios.class));    ///O que fazer aqui?
        }
    });

    botaoAgenda.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {

            Uri uri = Uri.parse("http://www.agendanatal.com.br");
            Intent intent = new Intent(Intent.ACTION_VIEW, uri);
            startActivity(intent);

        }
    });

    return rootView;
}

Tenho a Classe Passeios extends fragments

public class Passeios extends Fragment {

private ArrayList<HashMap<String, String>> list;
private ExpandableListAdapter listAdapter;
private ExpandableListView expListView;
private List<String> listDataHeader;
private HashMap<String, List<String>> listDataChild;
private WebView webView;
private View rootView;

@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    rootView = inflater.inflate(R.layout.guia_passeios, null);

    expListView = (ExpandableListView) rootView.findViewById(R.id.listaexp);

    prepareListData();

    listAdapter = new ExpandableListAdapter(getActivity(), listDataHeader, listDataChild);

    expListView.setAdapter(listAdapter);
    expandeAll();
    expListView.setOnChildClickListener(new ExpandableListView.OnChildClickListener() {

        @Override
        public boolean onChildClick(ExpandableListView parent, View v,
                                    int groupPosition, int childPosition, long id) {

            mudaTela(groupPosition, childPosition);

            return false;
        }
    });

    return rootView;
}

Como faco para iniciar a classe Passeios a partir da classe GuiaDaCidade? no metodo onclickListener da classe GuiaDaCidade ja tem +/- a ideia teorica do que quero, porem nao funciona.

Iniciar classe Fragment de outra Classe Fragment

Tenho uma classe GuiaDaCidade.

public class GuiaDaCidade extends Fragment {

    View rootView;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        rootView = inflater.inflate(R.layout.guia_da_cidade, null);

        View botaoPasseios = (View) rootView.findViewById(R.id.btpasseios);
        View botaoAgenda = (View) rootView.findViewById(R.id.btagenda);

        botaoPasseios.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                startActivity(new Intent(getActivity(),Passeios.class));    ///O que fazer aqui?
            }
        });

        botaoAgenda.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {

                Uri uri = Uri.parse("http://www.agendanatal.com.br");
                Intent intent = new Intent(Intent.ACTION_VIEW, uri);
                startActivity(intent);

            }
        });

        return rootView;
    }

E a Classe Passeios:

public class Passeios extends Fragment {

    private ArrayList<HashMap<String, String>> list;
    private ExpandableListAdapter listAdapter;
    private ExpandableListView expListView;
    private List<String> listDataHeader;
    private HashMap<String, List<String>> listDataChild;
    private WebView webView;
    private View rootView;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        rootView = inflater.inflate(R.layout.guia_passeios, null);

        expListView = (ExpandableListView) rootView.findViewById(R.id.listaexp);

        prepareListData();

        listAdapter = new ExpandableListAdapter(getActivity(), listDataHeader, listDataChild);

        expListView.setAdapter(listAdapter);
        expandeAll();
        expListView.setOnChildClickListener(new ExpandableListView.OnChildClickListener() {

            @Override
            public boolean onChildClick(ExpandableListView parent, View v,
                                        int groupPosition, int childPosition, long id) {

                mudaTela(groupPosition, childPosition);

                return false;
            }
        });

        return rootView;
    }

Como faco para iniciar a classe Passeios a partir da classe GuiaDaCidade? No metodo onclickListener da classe GuiaDaCidade ja tem +/- a ideia teórica do que quero, porem não funciona.

Fonte Link

Iniciar classe Fragment de outra Classe Fragment (Android)

//Imports

Tenho uma classe GuiaDaCidade extends Fragments.

public class GuiaDaCidade extends Fragment {

View rootView;

@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    rootView = inflater.inflate(R.layout.guia_da_cidade, null);

    View botaoPasseios = (View) rootView.findViewById(R.id.btpasseios);
    View botaoAgenda = (View) rootView.findViewById(R.id.btagenda);

    botaoPasseios.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            startActivity(new Intent(getActivity(),Passeios.class));    ///O que fazer aqui?
        }
    });

    botaoAgenda.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {

            Uri uri = Uri.parse("http://www.agendanatal.com.br");
            Intent intent = new Intent(Intent.ACTION_VIEW, uri);
            startActivity(intent);

        }
    });

    return rootView;
}

Tenho a Classe Passeios extends fragments

public class Passeios extends Fragment {

private ArrayList<HashMap<String, String>> list;
private ExpandableListAdapter listAdapter;
private ExpandableListView expListView;
private List<String> listDataHeader;
private HashMap<String, List<String>> listDataChild;
private WebView webView;
private View rootView;

@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    rootView = inflater.inflate(R.layout.guia_passeios, null);

    expListView = (ExpandableListView) rootView.findViewById(R.id.listaexp);

    prepareListData();

    listAdapter = new ExpandableListAdapter(getActivity(), listDataHeader, listDataChild);

    expListView.setAdapter(listAdapter);
    expandeAll();
    expListView.setOnChildClickListener(new ExpandableListView.OnChildClickListener() {

        @Override
        public boolean onChildClick(ExpandableListView parent, View v,
                                    int groupPosition, int childPosition, long id) {

            mudaTela(groupPosition, childPosition);

            return false;
        }
    });

    return rootView;
}

Como faco para iniciar a classe Passeios a partir da classe GuiaDaCidade? no metodo onclickListener da classe GuiaDaCidade ja tem +/- a ideia teorica do que quero, porem nao funciona.