2016-07-30 16 views
1

Sobald ich eine Spinner in meinem Xml hinzugefügt habe, bekam ich eine Exception raised during rendering: Binary XML file line #-1: Error inflating class <unknown>.android Spinner: Ausnahme beim Rendern ausgelöst

Klicken Sie auf die Details, ich sehe den folgenden Fehler.

Ich fülle die Spinner programmgesteuert.

enter image description here

Hier ist meine XML:

<?xml version="1.0" encoding="utf-8"?> 
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:padding="10dp" 
    android:weightSum="2"> 

    <TableRow 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_gravity="center_horizontal"> 

     <TextView 
      android:id="@+id/title" 
      android:layout_weight="2" 
      android:textAppearance="?android:attr/textAppearanceLarge" /> 
    </TableRow> 

    <TableRow 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_gravity="left"> 

     <TextView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="@string/title" /> 

     <EditText 
      android:id="@+id/name" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" /> 
    </TableRow> 

    <TableRow 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_gravity="left"> 

     <TextView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="@string/description" /> 

     <EditText 
      android:id="@+id/description" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:inputType="textMultiLine" /> 
    </TableRow> 

    <TableRow 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_gravity="left"> 

     <TextView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="@string/packaging" /> 

     <EditText 
      android:id="@+id/packaging" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:inputType="textMultiLine" /> 
    </TableRow> 

    <TableRow 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_gravity="left"> 

     <TextView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="@string/price" /> 

     <EditText 
      android:id="@+id/price" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:inputType="numberDecimal" /> 
    </TableRow> 

    <TableRow 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_gravity="left"> 

     <TextView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="@string/available_count" /> 

     <EditText 
      android:id="@+id/availableCount" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:inputType="number" /> 
    </TableRow> 

    <TableRow 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_gravity="left"> 

     <TextView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="@string/category" /> 

     <Spinner 
      android:id="@+id/category" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:spinnerMode="dropdown" /> 
    </TableRow> 

    <TableRow 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_gravity="center_horizontal"> 

     <Button 
      android:id="@+id/save_product" 
      android:layout_weight="2" 
      android:text="@string/change_product_details" /> 
    </TableRow> 

</TableLayout> 

Antwort

2

Ihr Code sieht gut android Studio kann nicht in der Lage, den Code neu zu erstellen Lassen Sie uns den Code neu erstellen und erneut ausführen.

+0

vielen Dank! es funktionierte. :) dumme Fehler – XeniaSis

+0

Verwenden Sie die neueste Version 2.2 von Android Studio es wird so viele dieser Art von Problemen zu lösen. Es ist auch leicht, als alle vorherigen Versionen. –

+0

die neueste Version, die ich auf ihrer Website sehe und die, die ich habe, ist 2.1 – XeniaSis