Hi guys, I want to inflate a childView of ExpandableChildView component.
Code:
public View getChildView(int groupPosition, int childPosition, boolean isLastChild, View convertView, ViewGroup parent) {
View v = convertView;
LinearLayout linearOpt = themesOptions.get(childPosition);
if(v == null) {
v = mInflater.inflate(R.layout.itemrow, null);
}
LinearLayout ll = (LinearLayout) v.findViewById(R.id.root);
ll.addView(linearOpt);
return v;
}
Where linearOpt is a vector that contains a lot of LinearLayout objects that I have instantiated.
private void prepareThemes(){
View v = mInflater.inflate(R.layout.widget_configure, null);
LinearLayout theme = (LinearLayout) v.findViewById(R.id.themeLayout);
LinearLayout color = (LinearLayout) v.findViewById(R.id.colorLayout);
LinearLayout trans = (LinearLayout) v.findViewById(R.id.transpLayout);
themesOptions.add(theme);
themesOptions.add(color);
themesOptions.add(trans);
}
This is R.layout.itemrow xml:
But I received this error:
07-18 10:48:49.740: ERROR/AndroidRuntime(2738): java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.
How I can resolve this issue?