Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid - fragment: InflateException
    primarykey
    data
    text
    <p>i'm trying to do a simple exercise about fragments, in Android, but i've some errors and i don't know which is the problem. The applications consists in 2 fragments, one near the other one, making 2 rectangle (as i said, it only an exercise on the understanding of fragments), so this is my code:</p> <p><strong>File</strong>: <em>fragment1.xml</em></p> <pre><code> &lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" android:background="#00FF00" &gt; &lt;TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Questo è il frammento #1" android:textColor="#000000" android:textSize="25sp" /&gt; &lt;/LinearLayout&gt; </code></pre> <p>fragments2.xml is the same, from this, it changes only the background color and the text.</p> <p><strong>File</strong>: <em>main.xml</em></p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="horizontal" &gt; &lt;fragment android:name="com.tia.Fragments.Fragment1" android:id="@+id/fragment1" android:layout_weight="1" android:layout_width="0px" android:layout_height="match_parent" /&gt; &lt;fragment android:name="com.tia.Fragments.Fragment2" android:id="@+id/fragment2" android:layout_weight="1" android:layout_width="0px" android:layout_height="match_parent" /&gt; &lt;/LinearLayout&gt; </code></pre> <p><strong>File</strong>: <em>Fragment1.java</em></p> <pre><code>package com.tia.fragments; import android.app.Activity; import android.app.Fragment; import android.os.Bundle; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; public class Fragment1 extends Fragment { @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { return inflater.inflate(R.layout.fragment1, container,false); } } </code></pre> <p>file Fragment2.java is the same, changes only "R.layout.fragment2"</p> <p>Now, when i try to run it on the emulator i get this exception:</p> <pre><code>java.lang.RuntimeException: Unable to start activity ComponentInfo{com.tia.fragments/com.tia.fragments.FragmentsActivity}: android.view.InflateException: Binary XML file line #7: Error inflating class fragment </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload