Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to display data in spinner from json
    primarykey
    data
    text
    <p>I am retrieving values from a json url and then storing it in a string variable. Now I want to display that value in a spinner. I have created an array list in my strings.xml file. The xml file contains following code:</p> <pre><code>&lt;string name="credit_card_title"&gt;Card Type&lt;/string&gt; &lt;string-array name="credit_card"&gt; &lt;item &gt;Select&lt;/item&gt; &lt;item &gt;Visa&lt;/item&gt; &lt;item &gt;MC&lt;/item&gt; &lt;item &gt;Amex&lt;/item&gt; &lt;item &gt;Discover&lt;/item&gt; </code></pre> <p>my spinner code is: </p> <pre><code>&lt;Spinner android:id="@+id/crdtcrd_crdtype" android:layout_width="match_parent" android:layout_height="wrap_content" android:entries="@array/credit_card" android:prompt="@string/credit_card_title" /&gt; </code></pre> <p>After retriving the value from the json url I am storing it in variable name <code>String cardtype</code></p> <p>Now how can I display the value of <code>cardtype</code> in the Spinner <code>crtdcrd_crdtype</code>....</p> <p>the json url is:</p> <p><a href="http://mygogolfteetime.com/iphone/login/ramu@gmail.com/123456" rel="nofollow">http://mygogolfteetime.com/iphone/login/ramu@gmail.com/123456</a></p> <p>From this URL I have to retrieve the value of <code>cardtype</code> and after retrieving the value i have to display it in the spinner..</p> <p>There are different values for <code>cardype</code> like <code>visa, mc, amex and discover</code> All these values are in my <code>strings.xml</code> file and after retrieving the value I have to display it in Spinner..</p> <p>Need Help still not able to find the solution..</p> <p>I am trying to display the value of <code>cardtype</code> using the following code:</p> <pre><code>crdtcrd_crdtype.setSelection(cardtype); </code></pre> <p>But its showing a number of errors.. 1. Change to setSelected(..) 2. Change type of cardtype to int</p> <p>Thanks in advance...</p>
    singulars
    1. This table or related slice is empty.
    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