1

我正在尝试创建一个包含 Spinner 的 UI。这是 XML(微调器快要结束了):

 <?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>

现在,当我尝试启动活动时,在扩展此布局时应用程序崩溃并且错误是:

Binary XML file line #105: Error inflating class android.widget.Spinner

是什么原因?

4

1 回答 1

4

什么是角色?是一个<string-array>,那么

更改此行

 android:entries="@string/role" 

 android:entries="@array/role" 
于 2013-04-12T09:42:06.217 回答