]> iEval git - unical.git/commitdiff
Use arguments for TrivialFragment
authorMarius Gavrilescu <marius@ieval.ro>
Tue, 11 Jun 2013 10:25:42 +0000 (13:25 +0300)
committerMarius Gavrilescu <marius@ieval.ro>
Tue, 11 Jun 2013 10:25:42 +0000 (13:25 +0300)
src/ro/ieval/unical/AddEventActivity.java
src/ro/ieval/unical/TrivialFragment.java

index caa901557cff34d95600f7949f279d461020c4c8..42aa2f2ca4da591fbfb88d073d4edf7c9c055554 100644 (file)
@@ -19,9 +19,20 @@ public final class AddEventActivity extends Activity {
                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));
index 727814ae85dd6e45ddafe3df7719ea0e978f50e2..4c474e61730982882e42a28da73917d9877958e5 100644 (file)
@@ -7,13 +7,10 @@ import android.view.View;
 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);
     }
 }
This page took 0.023783 seconds and 4 git commands to generate.