final ActionBar.Tab t2 = actionBar.newTab().setText(this.getString(R.string.addevtab2));
final ActionBar.Tab t3 = actionBar.newTab().setText(this.getString(R.string.addevtab3));
- final Fragment f1 = new TrivialFragment(R.layout.add_event_basic_tab);
- final Fragment f2 = new TrivialFragment(R.layout.add_event_details_tab);
- final Fragment f3 = new TrivialFragment(R.layout.add_event_other_tab);
+ final Fragment f1 = new TrivialFragment();
+ final Bundle b1=new Bundle();
+ b1.putInt(TrivialFragment.ARGUMENT_LAYOUT, R.layout.add_event_basic_tab);
+ f1.setArguments(b1);
+
+ final Fragment f2 = new TrivialFragment();
+ final Bundle b2=new Bundle();
+ b2.putInt(TrivialFragment.ARGUMENT_LAYOUT, R.layout.add_event_details_tab);
+ f2.setArguments(b2);
+
+ final Fragment f3 = new TrivialFragment();
+ final Bundle b3=new Bundle();
+ b3.putInt(TrivialFragment.ARGUMENT_LAYOUT, R.layout.add_event_other_tab);
+ f3.setArguments(b3);
t1.setTabListener(new AddEventTabListener(f1));
t2.setTabListener(new AddEventTabListener(f2));
import android.view.ViewGroup;
public final class TrivialFragment extends Fragment {
- private final int layout;
- public TrivialFragment(final int layout){
- this.layout=layout;
- }
+ public static final String ARGUMENT_LAYOUT="layout";
@Override
public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) {
- return inflater.inflate(layout, container, false);
+ return inflater.inflate(getArguments().getInt(ARGUMENT_LAYOUT), container, false);
}
}