marcoms10 marcoms10 - 2 months ago 10
Android Question

How can I call a method from nested fragment

I have a fragment(this is one tab of my tabhost)

"fragA"
inside other fragment
"fragB"
but I need to call one method of
"fragB"
from
"fragA"
.
when I do from an activity, I do this:

FragB detailsFragment=(FragB)getSupportFragmentManager().findFragmentById(R.id.detailFragment);

detailsFragment.consultaWS(convertIntWebService(categoria),"Pdf");


please, help me

Answer

I could finally solve it this way, in fragA:

FragB parentFragment = (FragB) getChildFragmentManager()
                                      .findFragmentByTag("detallesFragBusqueda");
if (parentFragment != null) {
    parentFragment.consultaWS("", "AllPdf");
}