Reputation: 3858
I'm trying to create an UI that contains a Spinner. Here is the XML (the spinner is almost to the end):
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout style="@style/header" >
<Button
android:id="@+id/btnBack_profileEdit"
style="@style/header_button"
android:layout_gravity="center_vertical"
android:layout_margin="@dimen/default_button_padding"
android:background="@drawable/ic_button"
android:drawableLeft="@drawable/ic_back_arrow"
android:gravity="right|center_vertical"
android:text="@string/back"
android:textColor="@android:color/white"
android:textSize="@dimen/header_button_text" />
<TextView
android:id="@+id/title_profileEdit"
style="@style/header_text"
android:singleLine="true"
android:text="@string/my_profile" />
<ImageButton
android:id="@+id/btnSave_profileEdit"
style="@style/header_button"
android:src="@drawable/ic_add" />
</LinearLayout>
<LinearLayout
style="@style/row"
android:background="@drawable/white_gradient" >
<TextView
style="@style/profile_row_content"
android:text="@string/first_name"
android:textColor="@color/black_text" />
<EditText
android:id="@+id/firstName_profileEdit"
style="@style/profile_row_edit_text"
android:imeOptions="actionNext" />
</LinearLayout>
<LinearLayout
style="@style/row"
android:background="@drawable/white_gradient" >
<TextView
style="@style/profile_row_content"
android:text="@string/last_name"
android:textColor="@color/black_text" />
<EditText
android:id="@+id/lastName_profileEdit"
style="@style/profile_row_edit_text"
android:imeOptions="actionNext" />
</LinearLayout>
<LinearLayout
style="@style/row"
android:background="@drawable/white_gradient" >
<TextView
style="@style/profile_row_content"
android:text="@string/email"
android:textColor="@color/black_text" />
<EditText
android:id="@+id/email_profileEdit"
style="@style/profile_row_edit_text"
android:imeOptions="actionNext" />
</LinearLayout>
<LinearLayout
style="@style/row"
android:background="@drawable/white_gradient" >
<TextView
style="@style/profile_row_content"
android:text="@string/password"
android:textColor="@color/black_text" />
<EditText
android:id="@+id/password_profileEdit"
style="@style/profile_row_edit_text"
android:imeOptions="actionNext"
android:inputType="textPassword" />
</LinearLayout>
<LinearLayout
android:id="@+id/lytRole_profileEdit"
style="@style/row"
android:background="@drawable/white_gradient" >
<TextView
style="@style/profile_row_content"
android:text="@string/role"
android:textColor="@color/black_text" />
<Spinner
android:id="@+id/role_profileEdit"
android:layout_width="match_parent"
android:gravity="center_vertical"
android:layout_height="wrap_content"
android:layout_weight=".5"
android:entries="@string/role" />
</LinearLayout>
<LinearLayout
android:id="@+id/lytSeparator_profileEdit"
style="@style/separator" >
<TextView
style="@style/separator_content"
android:text="@string/nickname_for_my_profile" />
</LinearLayout>
<LinearLayout
style="@style/row"
android:id="@+id/lytNickname_profileEdit"
android:background="@drawable/white_gradient" >
<TextView
style="@style/profile_row_content"
android:text="@string/nickname"
android:textColor="@color/black_text" />
<EditText
android:id="@+id/nickname_profileEdit"
style="@style/profile_row_edit_text"
android:layout_height="wrap_content" />
</LinearLayout>
</LinearLayout>
Now, when I'm trying to start the activity, on inflating this layout the app crash and the error is:
Binary XML file line #105: Error inflating class android.widget.Spinner
What is the reason?
Upvotes: 2
Views: 7075
Reputation: 13825
What is role? Is is an <string-array>
, then
Change this line
android:entries="@string/role"
to
android:entries="@array/role"
Upvotes: 4