From 2fdbb2e5bb09cbbcef99a055188fa3239dbcb3bd Mon Sep 17 00:00:00 2001 From: Ricky Barrette Date: Tue, 22 May 2012 21:21:56 -0400 Subject: [PATCH] Inital commit of the new dynamic Fragment list. This fragment no longer uses a listview or an adapter Signed-off-by: Ricky Barrette --- .../res/layout/fragment_list_contianer.xml | 20 +++--- .../ui/fragments/FeatureListFragment.java | 72 +++++++++---------- 2 files changed, 43 insertions(+), 49 deletions(-) diff --git a/LocationRinger/res/layout/fragment_list_contianer.xml b/LocationRinger/res/layout/fragment_list_contianer.xml index 4786db8..5d0a8ef 100644 --- a/LocationRinger/res/layout/fragment_list_contianer.xml +++ b/LocationRinger/res/layout/fragment_list_contianer.xml @@ -1,10 +1,12 @@ - - - + + + + + \ No newline at end of file diff --git a/LocationRinger/src/com/TwentyCodes/android/LocationRinger/ui/fragments/FeatureListFragment.java b/LocationRinger/src/com/TwentyCodes/android/LocationRinger/ui/fragments/FeatureListFragment.java index ae0c638..14a7381 100644 --- a/LocationRinger/src/com/TwentyCodes/android/LocationRinger/ui/fragments/FeatureListFragment.java +++ b/LocationRinger/src/com/TwentyCodes/android/LocationRinger/ui/fragments/FeatureListFragment.java @@ -11,19 +11,18 @@ import java.util.ArrayList; import android.content.ContentValues; import android.os.Bundle; import android.support.v4.app.Fragment; +import android.support.v4.app.FragmentManager; +import android.support.v4.app.FragmentTransaction; import android.support.v4.app.ListFragment; import android.util.Log; -import android.view.ContextMenu; -import android.view.ContextMenu.ContextMenuInfo; import android.view.LayoutInflater; -import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; -import android.widget.Toast; import com.TwentyCodes.android.LocationRinger.OnContentChangedListener; import com.TwentyCodes.android.LocationRinger.R; import com.TwentyCodes.android.LocationRinger.debug.Debug; +import com.TwentyCodes.android.LocationRinger.ui.fragments.FragmentListAdaptor.Holder; /** * This fragment will be used to display a list of fragments @@ -33,7 +32,16 @@ import com.TwentyCodes.android.LocationRinger.debug.Debug; * * @author ricky */ -public class FeatureListFragment extends ListFragment { +public class FeatureListFragment extends Fragment { + + + private static final String TAG = "FeatureListFragment"; + private final ArrayList mFragments; + + public FeatureListFragment(ContentValues info, OnContentChangedListener listener, ArrayList fragments) { + super(); + mFragments = fragments; + } /** * (non-Javadoc) @@ -42,51 +50,35 @@ public class FeatureListFragment extends ListFragment { * android.view.ViewGroup, android.os.Bundle) */ @Override - public View onCreateView(LayoutInflater inflator, ViewGroup container, - Bundle bundle) { + public View onCreateView(LayoutInflater inflator, ViewGroup container, Bundle bundle) { // TODO Auto-generated method stub - return super.onCreateView(inflator, container, bundle); - } - - private static final String TAG = "FeatureListFragment"; - private static final int DELETE_ID = 0; - private ArrayList mFeatures; - - // private OnContentChangedListener mListener; - // private ContentValues mInfo; - // private int mIndex; - - public FeatureListFragment(ContentValues info, - OnContentChangedListener listener, ArrayList fragments) { - super(); - this.mFeatures = fragments; - // this.mInfo = info; - // this.mListener = listener; + + return inflator.inflate(R.layout.fragment_list_contianer, null); } @Override public void onResume() { - this.setListAdapter(new FragmentListAdaptor(this, mFeatures)); - this.getListView().setOnCreateContextMenuListener(this); if (Debug.DEBUG) Log.v(TAG, "onResume()"); + + loadFragments(); super.onResume(); } - public void onCreateContextMenu(ContextMenu menu, View v, - ContextMenuInfo menuInfo) { - super.onCreateContextMenu(menu, v, menuInfo); - menu.add(0, DELETE_ID, 0, R.string.delete).setIcon( - android.R.drawable.ic_menu_delete); - } - - public boolean onContextItemSelected(MenuItem item) { - switch (item.getItemId()) { - case DELETE_ID: - Toast.makeText(this.getActivity(), "deleted! (note really)", - Toast.LENGTH_LONG).show(); - return true; + private void loadFragments() { + FragmentTransaction transaction = this.getFragmentManager().beginTransaction(); + for(Fragment fragment : this.mFragments){ + transaction.add(R.id.fragment_list_contianer, fragment, fragment.getTag()); } - return super.onContextItemSelected(item); + transaction.commit(); + } + + /** + * Simple Holder class + * @author ricky barrette + */ + class Holder{ + public String tag; + public View view; } } \ No newline at end of file