Note that there are some explanatory texts on larger screens.

plurals
  1. POSpinner array with spinner array values
    primarykey
    data
    text
    <p>Having a bit of a problem with my spinner, I am populating my spinner with my list with and array and that works, but when that is selected I am trying to populate my textview with the associated value.... Could someone perhaps point me in the right direction... Cheers</p> <pre><code>Spinner spinner1 = (Spinner) findViewById(R.id.spinner2); ArrayAdapter&lt;CharSequence&gt; adapter1 = ArrayAdapter.createFromResource( this, R.array.post_array, android.R.layout.simple_spinner_item); adapter1.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinner1.setAdapter(adapter1); final String post_array_values [] = getResources().getStringArray(R.array.post_array_values); /** */ spinner1.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { public void onItemSelected(AdapterView&lt;?&gt; parent, View view, int pos, long id) { txttvPS.setText(post_array_values[(int) id]); } public void onNothingSelected(AdapterView&lt;?&gt; arg0) { // TODO Auto-generated method stub } }); </code></pre> <p>Here is my array and array value</p> <pre><code>&lt;!-- String Array for Post Spinner --&gt; &lt;string name="post_picker"&gt;&lt;/string&gt; &lt;!-- Add Name if wanted between picker and before string close --&gt; &lt;string-array name="post_array"&gt; &lt;item&gt;-- Select Prov --&lt;/item&gt; &lt;item&gt;BC&lt;/item&gt; &lt;item&gt;Alberta&lt;/item&gt; &lt;item&gt;Manitoba&lt;/item&gt; &lt;item&gt;Ontario&lt;/item&gt; &lt;item&gt;Quebec&lt;/item&gt; &lt;/string-array&gt; &lt;string-array name="post_array_values"&gt; &lt;item&gt;0&lt;/item&gt;&lt;!-- Prov --&gt; &lt;item&gt;2.25&lt;/item&gt;&lt;!-- BC --&gt; &lt;item&gt;12.25&lt;/item&gt;&lt;!-- Alberta --&gt; &lt;item&gt;30.25&lt;/item&gt;&lt;!-- Manitoba --&gt; &lt;item&gt;56.25&lt;/item&gt;&lt;!-- Ontario --&gt; &lt;item&gt;90.25&lt;/item&gt;&lt;!-- Quebec --&gt; &lt;/string-array&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload