Error "Binary XML file line #22: Error inflating class Fragment"

Asked

Viewed 992 times

1

I believe the error occurs due to lack of memory. I get the following exception. When I enter the application and minimize the same, then I enter several applications minimizing the ones that were opened, I go back to the main application, gives the error of "Application stopped".

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.AndroidExplorer/com.AndroidExplorer.MainTab}: android.view.InflateException: Binary XML file line #22: Error inflating class fragment at android.app.Activitythread.performLaunchActivity(Activitythread.java:2121) at android.app.Activitythread.handleLaunchActivity(Activitythread.java:2146) at android.app.Activitythread.handleRelaunchActivity(Activitythread.java:3590) at android.app.Activitythread.access$800(Activitythread.java:140) at android.app.Activitythread$H.handleMessage(Activitythread.java:1244) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:137) at android.app.Activitythread.main(Activitythread.java:4947) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:511) at com.android.Internal.os.Zygoteinit$Methodandargscaller.run(Zygoteinit.java:1038) at com.android.Internal.os.Zygoteinit.main(Zygoteinit.java:805) at Dalvik.system.Nativestart.main(Native Method) Caused by: android.view.Inflateexception: Binary XML file line #22: Error inflating class Fragment at android.view.Layoutinflater.createViewFromTag(Layoutinflater.java:710) at android.view.Layoutinflater.rInflate(Layoutinflater.java:752) at android.view.Layoutinflater.rInflate(Layoutinflater.java:760) at android.view.Layoutinflater.inflate(Layoutinflater.java:495) at android.view.Layoutinflater.inflate(Layoutinflater.java:397) at android.view.Layoutinflater.inflate(Layoutinflater.java:353) com.android.Internal.policy.impl.PhoneWindow.setContentView(Phonewindow.java:318) at android.app.Activity.setContentView(Activity.java:1925) at com.AndroidExplorer.Maintab.onCreate(Maintab.java:78) at android.app.Activity.performCreate(Activity.java:5207) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1094) at android.app.Activitythread.performLaunchActivity(Activitythread.java:2085) ... 12 more Caused by: java.lang.Illegalstateexception: Fragment com.AndroidExplorer.Clientetab Did not create a view. at android.support.v4.app.Fragmentactivity.onCreateView(Fragmentactivity.java:295) at android.view.Layoutinflater.createViewFromTag(Layoutinflater.java:682) ... 23 more

  • 2

    The error itself doesn’t say much. Put your code (layouts, activities, Fragment, etc). Something may have been poorly implemented.

  • The error is only little but it seems that you have not implemented the method correctly onCreateView() of Fragment Clientetab.

  • Yes, thank you for answering

  • I put some classes below, of the possible problem, there is not an expected result yet. Maybe the problem occurs while rebuilding the screen.

3 answers

0

Class: clientTab.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    System.out.println("teste antes de inflar layout");
    view = inflater.inflate(R.layout.clientetab, container, false);
    System.out.println("teste depois de inflar layout");

    // Define a imagem de fundo de acordo com a orientacao do dispositivo
    if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT)
        view.setBackgroundResource(R.drawable.fundocadastro);
    else
        view.setBackgroundResource(R.drawable.fundocadastro);

    instanciate();
    return view;
}

0

xml clientetab.

<TextView android:text="Entrevistado:" android:id="@+id/txtEntrevistado" android:textSize="15dp" android:textColor="@color/textColor" android:layout_width="wrap_content" android:layout_height="wrap_content" ></TextView>
<Spinner android:id="@+id/spinnerEntrevistado" android:layout_height="wrap_content" android:drawSelectorOnTop="true" android:layout_width="fill_parent"></Spinner>

<TextView android:id="@+id/txtUsuario" android:textSize="18dp" android:text="Usuário do imóvel:" android:textColor="@color/textColor" android:layout_width="wrap_content" android:layout_height="wrap_content" > </TextView>
<EditText android:id="@+id/nomeUsuario" android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="@drawable/edittext_rounded_corners" android:inputType="textCapCharacters" android:maxLength="50" ><requestFocus></requestFocus> </EditText>

<TextView android:text="Tipo de Pessoa:" android:id="@+id/txtTipo_pessoa" android:textSize="15dp" android:textColor="@color/textColor" android:layout_width="wrap_content" android:layout_height="wrap_content" ></TextView>
<Spinner android:id="@+id/spinnerTipoPessoaUsuario" android:layout_height="wrap_content" android:drawSelectorOnTop="true" android:layout_width="fill_parent"></Spinner>

<LinearLayout     android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="wrap_content" android:id="@+id/linearLayout1">
    <TextView android:text="CPF:" android:id="@+id/txtCpfCnpjUsuario" android:minWidth="180dp" android:textSize="15dp" android:textColor="@color/textColor" android:layout_width="wrap_content" android:layout_height="wrap_content" ></TextView>
    <TextView android:text="RG:" android:id="@+id/txtRgUsuario" android:textSize="15dp" android:textColor="@color/textColor" android:layout_width="wrap_content" android:layout_height="wrap_content"></TextView>
</LinearLayout>

<LinearLayout     android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="wrap_content" android:id="@+id/linearLayout2">
    <EditText android:id="@+id/cpfCnpjUsuario" android:minWidth="150dp" android:maxLength="18" android:background="@drawable/edittext_rounded_corners" android:layout_width="wrap_content" android:layout_height="wrap_content" android:inputType="number"></EditText>
    <EditText android:id="@+id/rgUsuario" android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="@drawable/edittext_rounded_corners" android:inputType="number" android:maxLength="13" ></EditText>
</LinearLayout>

<LinearLayout     android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="wrap_content" android:id="@+id/linearLayout3">
    <TextView android:text="UF:" android:id="@+id/uf" android:minWidth="110dp" android:textSize="15dp" android:textColor="@color/textColor" android:layout_width="wrap_content" android:layout_height="wrap_content" ></TextView>
    <TextView android:text="Sexo:" android:id="@+id/sexo" android:textSize="15dp" android:textColor="@color/textColor" android:layout_width="wrap_content" android:layout_height="wrap_content"></TextView>
</LinearLayout>

<LinearLayout     android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="wrap_content" android:id="@+id/linearLayout4">
    <EditText android:id="@+id/ufUsuario" android:minWidth="50dp" android:background="@drawable/edittext_rounded_corners" android:layout_height="wrap_content" android:drawSelectorOnTop="true" android:layout_width="wrap_content" android:maxLength="2" android:inputType="textCapCharacters"></EditText>
    <Spinner android:id="@+id/spinnerSexoUsuario" android:minWidth="200dp" android:layout_height="wrap_content" android:drawSelectorOnTop="true" android:layout_width="fill_parent"></Spinner>
</LinearLayout>

<LinearLayout     android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="wrap_content" android:id="@+id/linearLayout5">
    <TextView android:text="Telefone:" android:id="@+id/txtTelefone" android:minWidth="150dp" android:textSize="15dp" android:textColor="@color/textColor" android:layout_width="wrap_content" android:layout_height="wrap_content"></TextView>
    <TextView android:text="Celular:" android:id="@+id/txtCelular" android:textSize="15dp" android:textColor="@color/textColor" android:layout_width="wrap_content" android:layout_height="wrap_content" ></TextView>
</LinearLayout>

<LinearLayout     android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="wrap_content" android:id="@+id/linearLayout6">
    <EditText android:id="@+id/foneUsuario" android:minWidth="150dp" android:background="@drawable/edittext_rounded_corners" android:layout_width="wrap_content" android:layout_height="wrap_content" android:maxLength="14" android:inputType="phone"></EditText>
    <EditText android:id="@+id/celularUsuario" android:background="@drawable/edittext_rounded_corners" android:layout_width="fill_parent" android:layout_height="wrap_content" android:maxLength="14" android:inputType="phone"></EditText>
</LinearLayout>

<TextView android:text="E-mail:" android:id="@+id/txtEmailUsuario" android:textSize="15dp" android:textColor="@color/textColor" android:layout_width="wrap_content" android:layout_height="wrap_content" ></TextView>
<EditText android:id="@+id/emailUsuario" android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="@drawable/edittext_rounded_corners" android:inputType="textEmailAddress" android:maxLength="50" ></EditText>

<LinearLayout     android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="wrap_content" android:id="@+id/linearLayout7">
    <TextView android:text="Usuário é proprietário do imóvel:" android:id="@+id/txtUsuarioEProprietario" android:textSize="15dp" android:textColor="@color/textColor" android:layout_width="wrap_content" android:layout_height="wrap_content"></TextView>
</LinearLayout>

<LinearLayout     android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="wrap_content" android:id="@+id/linearLayout8">
    <RadioGroup android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal"    android:id="@+id/groupUsuarioEProprietario">
        <RadioButton android:text="Não" android:id="@+id/radioNao" android:layout_width="wrap_content" android:layout_height="wrap_content"></RadioButton>
        <RadioButton android:text="Sim" android:id="@+id/radioSim" android:layout_width="wrap_content" android:layout_height="wrap_content"></RadioButton>
    </RadioGroup>
</LinearLayout>

<LinearLayout     android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="wrap_content" android:id="@+id/linearLayoutTextoTipoEnderecoUsuario">
    <TextView android:text="Tipo de endereço do proprietário:" android:id="@+id/txtTipoEnderecoUsuario" android:textSize="15dp" android:textColor="@color/textColor" android:layout_width="wrap_content" android:layout_height="wrap_content"></TextView>
</LinearLayout>

<LinearLayout     android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:id="@+id/linearLayoutTipoEnderecoUsuario">
    <RadioGroup android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal"    android:id="@+id/groupTipoEnderecoUsuario">
        <RadioButton android:text="Residencial" android:id="@+id/radioResidencial" android:layout_width="wrap_content" android:layout_height="wrap_content"></RadioButton>
        <RadioButton android:text="Comercial" android:id="@+id/radioComercial" android:layout_width="wrap_content" android:layout_height="wrap_content"></RadioButton>
    </RadioGroup>
</LinearLayout>

<LinearLayout     android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:id="@+id/linearLayoutUsuarioEProprietario">
</LinearLayout>

<TextView android:text="Responsável pelo Pagamento:" android:id="@+id/responsavelPagamento" android:textSize="15dp" android:textColor="@color/textColor" android:layout_width="wrap_content" android:layout_height="wrap_content" ></TextView>
<Spinner android:layout_height="wrap_content" android:id="@+id/spinnerDefineResponsavel" android:drawSelectorOnTop="true" android:layout_width="fill_parent"></Spinner>

<LinearLayout     android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:id="@+id/linearLayoutResponsavelPagamento">
</LinearLayout>

<LinearLayout     android:orientation="horizontal" android:paddingTop="5dp" android:paddingRight="5dp" android:layout_width="fill_parent" android:layout_height="wrap_content" android:id="@+id/linearLayoutPeriodo">
    <TextView android:id="@+id/list_item_text" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1" android:ellipsize="end" />
    <Button android:id="@+id/buttonSave" android:text="  OK  " android:textColor="@color/white" android:textSize="20dp" android:background="@drawable/button_rounded_corners" android:gravity="right" android:layout_weight="0" android:layout_width="wrap_content" android:layout_height="wrap_content" />
</LinearLayout>

0

mainTab

    <FrameLayout
        android:id="@android:id/tabcontent"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:layout_weight="0"/>

    <fragment android:name="com.AndroidExplorer.ClienteTab"
        android:id="@+id/tabCliente"
        android:layout_height="match_parent"
        android:layout_width="match_parent"
        android:padding="2dp" 
        android:scrollbars="vertical"/>

    <fragment android:name="com.AndroidExplorer.ImovelTab"
        android:id="@+id/tabImovel"
        android:layout_height="match_parent"
        android:layout_width="match_parent"
        android:padding="2dp" 
        android:scrollbars="vertical"
        android:visibility="gone"/>

    <fragment android:name="com.AndroidExplorer.ServicosTab"
        android:id="@+id/tabServicos"
        android:layout_height="match_parent"
        android:layout_width="match_parent"
        android:padding="2dp" 
        android:scrollbars="vertical"
        android:visibility="gone"/>

    <fragment android:name="com.AndroidExplorer.AnormalidadeTab"
        android:id="@+id/tabAnormalidade"
        android:layout_height="match_parent"
        android:layout_width="match_parent"
        android:padding="2dp" 
        android:scrollbars="vertical"
        android:visibility="gone"/>

</LinearLayout>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.