Reputation: 2354
As soon as I added a Spinner
in my xml, I got an Exception raised during rendering: Binary XML file line #-1: Error inflating class <unknown>
.
Clicking on the details, I see the following error.
I fill the Spinner
programmatically.
Here is my 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>
Upvotes: 1
Views: 706
Reputation: 406
Your code looks fine may be android studio not able to rebuild the code let's rebuild the code and run again.
Upvotes: 2