gpt4 book ai didi

android - 给 Spinner 充气时出错

转载 作者:行者123 更新时间:2023-11-29 18:01:17 24 4
gpt4 key购买 nike

我正在尝试创建一个包含 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>

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

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

这是什么原因?

最佳答案

什么是角色?是 <string-array> , 然后

改变这一行

 android:entries="@string/role" 

 android:entries="@array/role" 

关于android - 给 Spinner 充气时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15967887/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com