Fragmento getArguments () retorna nulo
eu tenho umFragment
que tem umTabHost
como o layout raiz da seguinte forma ...
<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TabWidget
android:id="@android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<FrameLayout
android:id="@+id/tab_1"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
<!-- More FrameLayouts here - each are placeholders for Fragments -->
</FrameLayout>
</LinearLayout>
</TabHost>
O código para criar / atualizar cadaFragment
para o conteúdo da guia é o seguinte ...
private void updateTab(String tabId, int placeholder) {
FragmentManager fm = getFragmentManager();
if (fm.findFragmentByTag(tabId) == null) {
Bundle arguments = new Bundle();
arguments.putInt("current_day", mCurrentTab);
EpgEventListFragment fragment = new EpgEventListFragment();
fragment.setArguments(arguments);
fm.beginTransaction()
.replace(placeholder, new EpgEventListFragment(), tabId)
.commit();
}
}
NoonCreate(...)
método doEpgEventListFragment
Eu então tento pegar os argumentosBundle
mas eu sempre recebonull
fazendo o seguinte ...
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Bundle arguments = getArguments();
if (arguments == null)
Toast.makeText(getActivity(), "Arguments is NULL", Toast.LENGTH_LONG).show();
else
mCurrentDay = getArguments().getInt("current_day", 0);
...
}
O que estou perdendo aqui? Eu também tenteigetArguments()
emonAttach(...)
mas ainda tenho nulo. Eu sou novo em usarFragments
então eu espero que haja uma razão simples, mas não encontrei nada ao pesquisar.