2012-12-10 1 views
2

Quand j'inclure un code barre de navigation xml dans mon autre xml, il génère l'erreur suivante:android: <include> tag erreur cause

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.my/com.my.Login}: android.view.InflateException: Binary XML file line #1: Error inflating class <unknown> 

login.xml est

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    style="@style/tableStyle" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical" > 

    <include 
     android:layout_height="wrap_content" 
     layout="@layout/navbar" /> 

</LinearLayout> 

navbar.xml est

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="@style/tableRowStyle" 
    android:orientation="horizontal" 
    android:paddingRight="0dp" > 

    <Button 
     android:id="@+id/button2" 
     android:layout_width="52dp" 
     android:layout_height="48dp" 
     android:background="@drawable/home" /> 

    <View 
     android:layout_width="1px" 
     android:layout_height="fill_parent" 
     android:background="#1f1f1f" /> 

    <View 
     android:layout_width="1px" 
     android:layout_height="fill_parent" 
     android:background="#454545" /> 

    <Button 
     android:id="@+id/button1" 
     android:layout_width="190dp" 
     android:layout_height="48dp" 
     android:layout_weight="0.35" 
     android:background="@drawable/stock" /> 

    <View 
     android:layout_width="1px" 
     android:layout_height="fill_parent" 
     android:background="#1f1f1f" /> 

    <View 
     android:layout_width="1px" 
     android:layout_height="fill_parent" 
     android:background="#454545" /> 

    <Button 
     android:id="@+id/button2" 
     android:layout_width="52dp" 
     android:layout_height="48dp" 
     android:background="@drawable/home" /> 

</LinearLayout> 

Quel est le problème derrière cela?

+0

Veuillez ajouter java Code –

Répondre

0

enlevé android:background="@style/tableRowStyle"

maintenant son fonctionne bien. Merci à tous pour vos précieuses réponses :)

0

Spécifiez également la largeur de la mise en page.

<include 
    android:layout_height="wrap_content" 
    android:layout_width="wrap_content" 
    layout="@layout/navbar" /> 
1

pourrait-il que

<include 
    android:layout_height="wrap_content" 
    layout="@layout/navbar" /> 

devrait être

<include 
    android:layout_height="wrap_content" 
    android:layout="@layout/navbar" /> 
1

java.lang.RuntimeException: Impossible de démarrer l'activité ComponentInfo {com.my/com.my.Login}: android.view.InflateException: ligne de fichier binaire XML # 1: Erreur classe de gonflage

Si vous avez cette erreur, cela signifie que l'appel de mise en page est incompatible dans votre setContentView (fichier R.id.xml); Alors vérifiez d'abord et assurez-vous que vous appelez l'ID de mise en page correctement dans votre code java.

Et supprimez simplement style = "@ style/tableStyle" dans votre fichier XML. Je pense que ça va marcher.

Questions connexes