From 756f5aea86e2f8d2408278d2d570dcb0474b0a3b Mon Sep 17 00:00:00 2001 From: Ricky Barrette Date: Fri, 11 May 2012 12:05:43 -0400 Subject: [PATCH] Got the fragment list adaptor working a little better Signed-off-by: Ricky Barrette --- .../ui/fragments/FragmentListAdaptor.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/LocationRinger/src/com/TwentyCodes/android/LocationRinger/ui/fragments/FragmentListAdaptor.java b/LocationRinger/src/com/TwentyCodes/android/LocationRinger/ui/fragments/FragmentListAdaptor.java index e3bca55..b237cf7 100644 --- a/LocationRinger/src/com/TwentyCodes/android/LocationRinger/ui/fragments/FragmentListAdaptor.java +++ b/LocationRinger/src/com/TwentyCodes/android/LocationRinger/ui/fragments/FragmentListAdaptor.java @@ -24,6 +24,7 @@ import com.TwentyCodes.android.LocationRinger.debug.Debug; /** * This Adaptor Class will be used to display fragments in a ListFragment. * TODO + * + Get this code working * + Add/Remove fragments on the fly * @author ricky barrette */ @@ -114,20 +115,21 @@ public class FragmentListAdaptor extends BaseAdapter { convertView.setTag(holder); //add the fragment to the new view - transaction.add(holder.view.getId(), getItem(position), holder.tag); +// transaction.add(holder.view.getId(), getItem(position), holder.tag); + transaction.replace(holder.view.getId(), getItem(position),holder.tag); } else { // Get the ViewHolder back to get fast access to the Old Views holder = (Holder) convertView.getTag(); Fragment shown = mFragmentManager.findFragmentByTag(holder.tag); //replace the old fragment with a new one + transaction.addToBackStack(holder.tag); holder.tag = createTag(position); if(shown != null) transaction.remove(shown); - transaction.add(holder.view.getId(), getItem(position), holder.tag); - transaction.addToBackStack(null); +// transaction.add(holder.view.getId(), getItem(position), holder.tag); + transaction.replace(holder.view.getId(), getItem(position),holder.tag); } - transaction.commit(); return convertView;