HI

I have a fragment inside a fragment that is causing trouble.. it works at
first, but it's hosted in a tabbed view, and when I either select another
tab then return, or simply change the device's orientation, I get an
inflateexception when inflating the fragment layout (in the first line of
CallCreationFragment.OnCreateView).

Fragment Code

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android";
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >
  <Button
    android:text="@string/pick_contact"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:id="@+id/selectContactButton" 
    android:layout_marginBottom="30dp"
    />
  <fragment class="SmartAppMobileAndroid.DialerFragment"
            android:id="@+id/dialer_fragment"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_marginBottom="10dp" />
</LinearLayout>

OnCreateView method: 

public override View OnCreateView(LayoutInflater inflater, ViewGroup
container, Bundle savedInstanceState)
        {
            View fragment =
inflater.Inflate(Resource.Layout.CallCreationFragment, null, false);
            if (container == null)
                Log.Debug("MyApp", "CallCreation fragment is in a view
without container");

            Button myButton =
fragment.FindViewById<Button>(Resource.Id.selectContactButton);
            if (myButton != null && !buttonAssigned)
            {
                myButton.Click += (sender, e) => 
                {
                    
                };
                buttonAssigned = true;
            }
            return fragment;
        }



And DialerFragment

<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android";
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:id="@+id/tableLayout1"
    android:shrinkColumns="*"
    android:stretchColumns="*">
    <TableRow
        android:id="@+id/tableRow1"
        android:layout_height="wrap_content"
        android:layout_width="match_parent">
        <EditText
            android:inputType="number"
            android:layout_column="0"
            android:id="@+id/editText1"
            android:layout_span="2" />
        <Button
            android:text="@string/delete_button"
            android:layout_column="1"
            android:id="@+id/deleteButton"
            android:background="?android:attr/selectableItemBackground" />
    </TableRow>
    <TableRow
        android:id="@+id/tableRow2"
        android:layout_height="wrap_content"
        android:layout_width="match_parent">
        <Button
            android:text="1"
            android:layout_column="0"
            android:id="@+id/number1Button" />
        <Button
            android:text="2"
            android:layout_column="1"
            android:id="@+id/number2Button" />
        <Button
            android:text="3"
            android:layout_column="2"
            android:id="@+id/number3Button" />
    </TableRow>
    <TableRow
        android:id="@+id/tableRow3"
        android:layout_height="wrap_content"
        android:layout_width="match_parent">
        <Button
            android:text="4"
            android:layout_column="0"
            android:id="@+id/number4Button" />
        <Button
            android:text="5"
            android:layout_column="1"
            android:id="@+id/number5Button" />
        <Button
            android:text="6"
            android:layout_column="2"
            android:id="@+id/number6Button" />
    </TableRow>
    <TableRow
        android:id="@+id/tableRow4"
        android:layout_height="wrap_content"
        android:layout_width="match_parent">
        <Button
            android:text="7"
            android:layout_column="0"
            android:id="@+id/number7Button" />
        <Button
            android:text="8"
            android:layout_column="1"
            android:id="@+id/number8Button" />
        <Button
            android:text="9"
            android:layout_column="2"
            android:id="@+id/number9Button" />
    </TableRow>
    <TableRow
        android:id="@+id/tableRow5">
        <Button
            android:text="*"
            android:layout_column="0"
            android:id="@+id/starButton" />
        <Button
            android:text="0"
            android:layout_column="1"
            android:id="@+id/number0Button" />
        <Button
            android:text="#"
            android:layout_column="2"
            android:id="@+id/hashButton" />
    </TableRow>
    <TableRow
        android:id="@+id/tableRow6">
        <Button
            android:text="@string/dial"
            android:layout_column="1"
            android:id="@+id/dialButton"/>
    </TableRow>
</TableLayout>

And the matching OnCreateview:

public override View OnCreateView(LayoutInflater inflater, ViewGroup
container, Bundle savedInstanceState)
        {
            View fragment = null;
            if (container == null)
            {
                Log.Debug("SmartApp", "Dialer Fragment is in a view without
container");
                fragment = inflater.Inflate(Resource.Layout.DialerFragment,
null);
                //return null;
            }
            else
                fragment = inflater.Inflate(Resource.Layout.DialerFragment,
container, false);
return fragment;
}

I'm targeting API 14 with M4A 4.2.4.

I've tried giving null as second argument to Inflate with no success.
If instead of showing the entire CallCreationFragment I just show the
DialerFragment, I have no issues whatsoever.

Any ideas as to what I'm doing wrong this time?

Cheers
Stephan



--
View this message in context: 
http://mono-for-android.1047100.n5.nabble.com/Android-Views-InflateException-unable-to-inflate-Fragment-inside-Fragment-tp5711681.html
Sent from the Mono for Android mailing list archive at Nabble.com.
_______________________________________________
Monodroid mailing list
Monodroid@lists.ximian.com

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid

Reply via email to