Answer the question
In order to leave comments, you need to log in
ListView does not accept string-array as entries, how to fix?
The task is to make the ListView display 3 elements from the string array:
<string-array name="options">
<item>Drinks</item>
<item>Food</item>
<item>Stories</item>
</string-array>
<!--Начало кода стандартное-->
<ListView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/list_options"
android:entries="@array/options"/>
</LinearLayout>
Answer the question
In order to leave comments, you need to log in
String[] entriesList = getResources().getStringArray(R.array.options);
ListView listView = (ListView)findViewById(R.id.listView1);
adapter = new ArrayAdapter(...,entriesList);
listView.setAdapter(adapter);
Probably something like this, well, put it in the required initialization section (for example, onCreate or onOptionsItemSelected)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question