diff --git a/src/in/srain/cube/views/GridViewWithHeaderAndFooter.java b/src/in/srain/cube/views/GridViewWithHeaderAndFooter.java index ce997f3..8630992 100644 --- a/src/in/srain/cube/views/GridViewWithHeaderAndFooter.java +++ b/src/in/srain/cube/views/GridViewWithHeaderAndFooter.java @@ -24,7 +24,14 @@ import android.util.Log; import android.view.View; import android.view.ViewGroup; -import android.widget.*; +import android.widget.AbsListView; +import android.widget.AdapterView; +import android.widget.Filter; +import android.widget.Filterable; +import android.widget.FrameLayout; +import android.widget.GridView; +import android.widget.ListAdapter; +import android.widget.WrapperListAdapter; import java.lang.reflect.Field; import java.util.ArrayList; @@ -156,6 +163,9 @@ public void addHeaderView(View v, Object data, boolean isSelectable) { v.setLayoutParams(new FrameLayout.LayoutParams(lyp.width, lyp.height)); fl.setLayoutParams(new AbsListView.LayoutParams(lyp.width, lyp.height)); } + + if (v.getParent() != null) + ((ViewGroup) v.getParent()).removeView(v); fl.addView(v); info.view = v; info.viewContainer = fl; @@ -189,6 +199,9 @@ public void addFooterView(View v, Object data, boolean isSelectable) { v.setLayoutParams(new FrameLayout.LayoutParams(lyp.width, lyp.height)); fl.setLayoutParams(new AbsListView.LayoutParams(lyp.width, lyp.height)); } + + if (v.getParent() != null) + ((ViewGroup) v.getParent()).removeView(v); fl.addView(v); info.view = v; info.viewContainer = fl;