I have a xml file named socio_form_organization.xml that have two layout's. This xml file is inflated in a layout named content how we can see by the code below
socio_form_organization.xml
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/sfo_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/background_tile"
android:orientation="vertical" >
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/sfo_layout2"
android:layout_width="wrap_content"
android:layout_height="51dp"
android:background="@drawable/background_tile"
android:baselineAligned="true"
android:orientation="horizontal">
<Button
android:id="@+id/sfo_btOrganization"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="2dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="2dp"
android:hint="@string/sfo_btOrganization" />
<EditText
android:id="@+id/sfo_etEmpresa"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="2dp"
android:layout_marginTop="2dp"
android:layout_weight="0.14"
android:hint="@string/sfo_etEmpresa"
android:inputType="textMultiLine"
android:scrollHorizontally="false" />
<ImageButton
android:id="@+id/sfo_ivRemove"
style="?android:attr/buttonStyleSmall"
android:layout_height="60dp"
android:layout_width="50dp"
android:layout_marginTop="2dp"
android:layout_marginBottom="2dp"
android:layout_marginRight="5dp"
android:onClick="onClick"
android:background="@android:color/transparent"
android:src="@drawable/tb_no_delete" />
</LinearLayout>
<EditText
android:id="@+id/sfo_etTitulo"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="2dp"
android:layout_marginLeft="65dp"
android:layout_marginRight="55dp"
android:layout_marginTop="2dp"
android:layout_weight="0.14"
android:hint="@string/sfo_etTitulo"
android:inputType="textMultiLine"
android:scrollHorizontally="false" />
</LinearLayout>
Layout where is inflated the socio_form_organization.xml
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/se_contentOrganization"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="2dp"
android:background="@drawable/background_tile"
android:orientation="vertical" >
<include
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="70dp"
layout="@layout/socio_form_organization" />
In my class i do the inflation
LayoutInflater inflaterOrganization=
(LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
LinearLayout organization =
(LinearLayout)inflaterOrganization.inflate(R.layout.socio_form_organization, null);
LinearLayout lLayoutOrganization;
lLayoutOrganization = (LinearLayout)findViewById(R.id.se_contentOrganization);
lLayoutOrganization.addView(organization);
But now á need to remove the two layout inside the content when i click in ImageButton but i can't.
I try with
View toRemove = (View) view.getParent();
ViewGroup vg = (ViewGroup)findViewById(R.id.se_content);
vg.removeView(toRemove);
But only works when I have one layout. In this case I have two layout and don't work.
I do not know if I could make you understand. Anyone can help me? Thanks