I learned how to send data from a fragment to your activity using the interface. But now I'm trying to do the reverse. Because I've sent data to an activity and want that data to be sent back to its fragments.
...
Thank you guys, sorry for the delay in answering and not explaining right, I'm new here and it's my first question. I was able to use the SmartTabLayout library to insert tabs into the activity. Instead of adding a text and fragment class in the FragmentPagerItemAdapter, I just added a FragmentPageItem already with the values I wanted to pass to the fragment. in this way:
FragmentPagerItem itemBranco = FragmentPagerItem.of("", BrancoFragment.class,
new Bundler().putSerializable("passarTipo", tipoProduto).get());
//Configurar abas
FragmentPagerItemAdapter adapter = new FragmentPagerItemAdapter(
getSupportFragmentManager(),
FragmentPagerItems.with(this)
.add(itemBranco)
.create()
);
And in the fragment I got the values using the onActivityCreated:
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
//Pegar o tipoProduto do EstoqueActivity
Bundle bundle = getArguments();
tipoProduto = (TipoProduto) bundle.getSerializable("passarTipo");
if (tipoProduto == null){
Toast.makeText(getActivity(), "O tipo produto é nulo", Toast.LENGTH_LONG).show();
}else {
Toast.makeText(getActivity(), "Valor tipo produto passado com sucesso", Toast.LENGTH_LONG).show();
}
}
I hope it can help anyone with the same problem when using this library, Embrace.