Reputation: 13
I have three spinners, two populated from code and the third is from XML arrays.xml. This third one is not showing any labels, just the empty lines for every item.
The error I get in Logcat:
W/ResourceType(22121): Failure getting entry for 0x010802c8 (t=7 e=712) in package 0 (error -75)
But I don't know what to do with this line... I did xml filled spinners earlier and they were ok, I don't know what i'm doing wrong...
My layout:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/text_from"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/text_from" />
<Spinner
android:id="@+id/spinner_start"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/text_from" />
<TextView
android:id="@+id/text_length"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/text_length"
android:layout_below="@id/spinner_start" />
<Spinner
android:id="@+id/spinner_length"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:entries="@array/length_value"
android:entryValues="@array/length_value"
android:defaultValue="10"
android:layout_below="@id/text_length" />
<CheckBox
android:id="@+id/check_from_lesson"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/check_from_lesson"
android:layout_below="@id/spinner_length" />
<Spinner
android:id="@+id/spinner_lesson"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/check_from_lesson" />
<Button
android:id="@+id/button_select_from_list"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/button_select"
android:layout_below="@id/spinner_lesson" />
<Button
android:id="@+id/button_ok"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/button_ok"
android:layout_below="@id/spinner_lesson"
android:layout_toRightOf="@id/button_select_from_list"
android:onClick="onOkButtonPress" />
</RelativeLayout>
My arrays.xml:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<array name="length_value">
<item>5</item>
<item>10</item>
<item>15</item>
<item>20</item>
<item>25</item>
</array>
</resources>
My code which calls the layout and populates the other 2 spinners:
public void setTestParams() {
setContentView(R.layout.main_popup_layout);
sp_lesson = (Spinner)findViewById(R.id.spinner_lesson);
Spinner sp_start = (Spinner)findViewById(R.id.spinner_start);
sp_lesson.setEnabled(false);
List<String> lessons = new ArrayList<String>();
List<String> start = new ArrayList<String>();
lessons=getLessons();
start=getStart();
ArrayAdapter<String> spAdapterStart = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, start);
ArrayAdapter<String> spAdapterLessons = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, lessons);
spAdapterStart.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spAdapterLessons.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
sp_start.setAdapter(spAdapterStart);
sp_lesson.setAdapter(spAdapterLessons);
spAdapterLessons.notifyDataSetChanged();
spAdapterStart.notifyDataSetChanged();
final CheckBox cb_lesson = (CheckBox)findViewById(R.id.check_from_lesson);
cb_lesson.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if(cb_lesson.isChecked()){
sp_lesson.setEnabled(true);
}else{
sp_lesson.setEnabled(false);
}
}
});
}
Upvotes: 0
Views: 783
Reputation: 18933
The Spinner in which you are getting your data from resource but can't found it
then you should add :
android:entries="@array/length_value"
to that Spinner in your xml file...
and also change it with:
<string-array name="length_value">
<item>5</item>
<item>10</item>
<item>15</item>
<item>20</item>
<item>25</item>
</string-array>
Upvotes: 1
Reputation: 28484
Try this :
<string-array name="length_value">
<item>5</item>
<item>10</item>
<item>15</item>
<item>20</item>
<item>25</item>
</string-array>
Upvotes: 0