2016-07-30 52 views
1

只要我在xml中添加了Spinner,我得到了一個Exception raised during rendering: Binary XML file line #-1: Error inflating class <unknown>android spinner:渲染過程中出現的異常

點擊詳細信息,我看到以下錯誤。我編寫了Spinner編程。

enter image description here

這裏是我的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> 

回答

2

您的代碼看起來不錯可能是機器人工作室無法重建代碼讓我們重建代碼,並再次運行。

+0

非常感謝!有效。 :)愚蠢的錯誤 – XeniaSis

+0

使用Android Studio的最新版本2.2它將解決這麼多類型的問題。這也是以前的所有版本的重量。 –

+0

我在他們的網站上看到的最新版本和我所擁有的最新版本是2.1 – XeniaSis

相關問題