Fragmento getArguments () devuelve nulo
tengo unFragment
que tiene unTabHost
como el diseño de la raíz de la siguiente manera ...
<?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>
El código para crear / actualizar cada uno.Fragment
El contenido de la pestaña es el siguiente ...
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();
}
}
En elonCreate(...)
método de laEpgEventListFragment
Entonces trato de conseguir los argumentos.Bundle
pero siempre consigonull
haciendo lo siguiente ...
@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);
...
}
¿Que me estoy perdiendo aqui? Yo tambien lo intentégetArguments()
enonAttach(...)
pero todavia tengo nulo Soy nuevo en usarFragments
así que espero que haya una razón simple, pero no he encontrado nada al buscar.