2016-07-30 6 views
1

xmlにSpinnerを追加するとすぐにException raised during rendering: Binary XML file line #-1: Error inflating class <unknown>が見つかりました。アンドロイドスピナー:レンダリング中に例外が発生しました

詳細をクリックすると、次のエラーが表示されます。

私は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スタジオの最新バージョン2.2を使用します。それは軽い重量であり、すべてのそれ以前のバージョンです。 –

+0

最新のバージョンは私のウェブサイトにあり、持っているものは2.1です。 – XeniaSis

関連する問題